Introduce o3tl::optional as an alias for std::optional

...with a boost::optional fallback for Xcode < 10 (as std::optional is only
available starting with Xcode 10 according to
<https://en.cppreference.com/w/cpp/compiler_support>, and our baseline for iOS
and macOS is still Xcode 9.3 according to README.md).  And mechanically rewrite
all code to use o3tl::optional instead of boost::optional.

One immediate benefit is that disabling -Wmaybe-uninitialized for GCC as per
fed7c3deb3f4ec81f78967c2d7f3c4554398cb9d "Slience bogus
-Werror=maybe-uninitialized" should no longer be necessary (and whose check
happened to no longer trigger for GCC 10 trunk, even though that compiler would
still emit bogus -Wmaybe-uninitialized for uses of boost::optional under
--enable-optimized, which made me ponder whether this switch from
boost::optional to std::optional would be a useful thing to do; I keep that
configure.ac check for now, though, and will only remove it in a follow up
commit).

Another longer-term benefit is that the code is now already in good shape for an
eventual switch to std::optional (a switch we would have done anyway once we no
longer need to support Xcode < 10).

Only desktop/qa/desktop_lib/test_desktop_lib.cxx heavily uses
boost::property_tree::ptree::get_child_optional returning boost::optional, so
let it keep using boost::optional for now.

After a number of preceding commits have paved the way for this change, this
commit is completely mechanical, done with

> git ls-files -z | grep -vz -e '^bin/find-unneeded-includes$' -e '^configure.ac$' -e '^desktop/qa/desktop_lib/test_desktop_lib.cxx$' -e '^dictionaries$' -e '^external/' -e '^helpcontent2$' -e '^include/IwyuFilter_include.yaml$' -e '^sc/IwyuFilter_sc.yaml$' -e '^solenv/gdb/boost/optional.py$' -e '^solenv/vs/LibreOffice.natvis$' -e '^translations$' -e '\.svg$' | xargs -0 sed -i -E -e 's|\<boost(/optional)?/optional\.hpp\>|o3tl/optional.hxx|g' -e 's/\<boost(\s*)::(\s*)(make_)?optional\>/o3tl\1::\2\3optional/g' -e 's/\<boost(\s*)::(\s*)none\>/o3tl\1::\2nullopt/g'

(before committing include/o3tl/optional.hxx, and relying on some GNU features).
It excludes some files where mention of boost::optional et al should apparently
not be changed (and the sub-repo directory stubs).  It turned out that all uses
of boost::none across the code base were in combination with boost::optional, so
had all to be rewritten as o3tl::nullopt.

Change-Id: Ibfd9f4b3d5a8aee6e6eed310b988c4e5ffd8b11b
Reviewed-on: https://gerrit.libreoffice.org/84128
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
diff --git a/accessibility/inc/pch/precompiled_acc.hxx b/accessibility/inc/pch/precompiled_acc.hxx
index e83c1a8..fe3ceeb 100644
--- a/accessibility/inc/pch/precompiled_acc.hxx
+++ b/accessibility/inc/pch/precompiled_acc.hxx
@@ -48,7 +48,7 @@
#include <typeinfo>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/basctl/inc/pch/precompiled_basctl.hxx b/basctl/inc/pch/precompiled_basctl.hxx
index d7951c4..f6db030 100644
--- a/basctl/inc/pch/precompiled_basctl.hxx
+++ b/basctl/inc/pch/precompiled_basctl.hxx
@@ -52,7 +52,7 @@
#include <utility>
#include <vector>
#include <boost/functional/hash.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx
index 8442747..73b30395 100644
--- a/basctl/source/inc/dlgedobj.hxx
+++ b/basctl/source/inc/dlgedobj.hxx
@@ -25,7 +25,7 @@
#include <com/sun/star/container/XContainerListener.hpp>
#include <svx/svdouno.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <map>

@@ -158,7 +158,7 @@ private:
    DlgEditor& rDlgEditor;
    std::vector<DlgEdObj*> pChildren;

    mutable ::boost::optional< css::awt::DeviceInfo >   mpDeviceInfo;
    mutable ::o3tl::optional< css::awt::DeviceInfo >   mpDeviceInfo;

private:
    explicit DlgEdForm(
diff --git a/basic/inc/pch/precompiled_sb.hxx b/basic/inc/pch/precompiled_sb.hxx
index ab5c6ce..203b756 100644
--- a/basic/inc/pch/precompiled_sb.hxx
+++ b/basic/inc/pch/precompiled_sb.hxx
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index f8bbafb..6a3cc72 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -24,14 +24,14 @@
#include <basic/sbx.hxx>
#include <runtime.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

using namespace std;

struct SbxVarEntry
{
    SbxVariableRef mpVar;
    boost::optional<OUString> maAlias;
    o3tl::optional<OUString> maAlias;
};


diff --git a/canvas/source/directx/dx_config.hxx b/canvas/source/directx/dx_config.hxx
index e93ef28..86c719f 100644
--- a/canvas/source/directx/dx_config.hxx
+++ b/canvas/source/directx/dx_config.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_CANVAS_SOURCE_DIRECTX_DX_CONFIG_HXX

#include <unotools/configitem.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <set>

namespace basegfx { class B2IVector; }
@@ -72,7 +72,7 @@ namespace dxcanvas
        virtual void               ImplCommit() override;
        typedef std::set< DeviceInfo > ValueSet;
        ValueSet                   maValues;
        boost::optional<sal_Int32> maMaxTextureSize;
        o3tl::optional<sal_Int32> maMaxTextureSize;
        bool                       mbBlacklistCurrentDevice;
        bool                       mbValuesDirty;
    };
diff --git a/chart2/inc/pch/precompiled_chartcontroller.hxx b/chart2/inc/pch/precompiled_chartcontroller.hxx
index febe636..da1c5a3 100644
--- a/chart2/inc/pch/precompiled_chartcontroller.hxx
+++ b/chart2/inc/pch/precompiled_chartcontroller.hxx
@@ -48,7 +48,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/chart2/inc/pch/precompiled_chartcore.hxx b/chart2/inc/pch/precompiled_chartcore.hxx
index 1ae17f7..f4d88ba 100644
--- a/chart2/inc/pch/precompiled_chartcore.hxx
+++ b/chart2/inc/pch/precompiled_chartcore.hxx
@@ -33,7 +33,7 @@
#include <string_view>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx
index 311ffdd..657e3d1 100644
--- a/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx
+++ b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx
@@ -22,7 +22,7 @@
#include "ItemConverter.hxx"
#include <com/sun/star/awt/Size.hpp>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace chart { namespace wrapper {

@@ -52,7 +52,7 @@ private:

    OUString m_aRefSizePropertyName;
    css::uno::Reference<css::beans::XPropertySet> m_xRefSizePropSet;
    boost::optional<css::awt::Size> m_pRefSize;
    o3tl::optional<css::awt::Size> m_pRefSize;
};

}}
diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx
index 45af3f1..c9bd687 100644
--- a/chart2/source/view/axes/VAxisProperties.hxx
+++ b/chart2/source/view/axes/VAxisProperties.hxx
@@ -30,7 +30,7 @@
#include <com/sun/star/uno/Any.hxx>

#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace chart { class ExplicitCategoriesProvider; }
namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } }
@@ -101,8 +101,8 @@ struct AxisProperties final
    css::chart::ChartAxisLabelPosition m_eLabelPos;
    css::chart::ChartAxisMarkPosition  m_eTickmarkPos;

    boost::optional<double> m_pfMainLinePositionAtOtherAxis;
    boost::optional<double> m_pfExrtaLinePositionAtOtherAxis;
    o3tl::optional<double> m_pfMainLinePositionAtOtherAxis;
    o3tl::optional<double> m_pfExrtaLinePositionAtOtherAxis;

    bool        m_bCrossingAxisHasReverseDirection;
    bool        m_bCrossingAxisIsCategoryAxes;
diff --git a/comphelper/inc/pch/precompiled_comphelper.hxx b/comphelper/inc/pch/precompiled_comphelper.hxx
index e94b3b6..61ff033 100644
--- a/comphelper/inc/pch/precompiled_comphelper.hxx
+++ b/comphelper/inc/pch/precompiled_comphelper.hxx
@@ -45,7 +45,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/conditn.hxx>
diff --git a/comphelper/qa/unit/variadictemplates.cxx b/comphelper/qa/unit/variadictemplates.cxx
index 20d47f8..587bded 100644
--- a/comphelper/qa/unit/variadictemplates.cxx
+++ b/comphelper/qa/unit/variadictemplates.cxx
@@ -7,7 +7,7 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <sal/types.h>
#include <comphelper/unwrapargs.hxx>
#include <cppunit/TestAssert.h>
@@ -56,7 +56,7 @@ void extract(
template <typename T>
void extract(
    ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any> const& seq,
    sal_Int32 nArg, ::boost::optional<T> & v,
    sal_Int32 nArg, ::o3tl::optional<T> & v,
    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>
    const& xErrorContext )
{
@@ -104,22 +104,22 @@ void VariadicTemplatesTest::testUnwrapArgs() {
    ::com::sun::star::uno::Any tmp9(
        ::com::sun::star::uno::makeAny( tmp4 )
        );
    ::boost::optional< ::com::sun::star::uno::Any > tmp10(
    ::o3tl::optional< ::com::sun::star::uno::Any > tmp10(
        ::com::sun::star::uno::makeAny( tmp5 )
        );
    ::boost::optional< ::com::sun::star::uno::Any > tmp11(
    ::o3tl::optional< ::com::sun::star::uno::Any > tmp11(
        ::com::sun::star::uno::makeAny( tmp1 )
        );

    // test equality with the baseline and template specialization with
    // boost::optional< T >
    // o3tl::optional< T >
    try {
        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > seq1(
            static_cast< sal_uInt32 >( 5 ) );
        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > seq2(
            static_cast< sal_uInt32 >( 5 ) );

        // tmp11 should be ignored as it is ::boost::optional< T >
        // tmp11 should be ignored as it is ::o3tl::optional< T >
        ::comphelper::unwrapArgs( seq1, tmp6, tmp7, tmp8, tmp9, tmp10, tmp11 );
        unwrapArgsBaseline( seq2, tmp6, tmp7, tmp8, tmp9, tmp10 );
        ::com::sun::star::uno::Any* p1 = seq1.getArray();
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
index c71c2ce..256315f 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
@@ -26,7 +26,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/util/XOfficeInstallationDirectories.hpp>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace com::sun::star::uno { class XComponentContext; }

@@ -72,8 +72,8 @@ private:
    void initDirs();

    css::uno::Reference< css::uno::XComponentContext >    m_xCtx;
    boost::optional<OUString>                  m_xOfficeBrandDir;
    boost::optional<OUString>                  m_xUserDir;
    o3tl::optional<OUString>                  m_xOfficeBrandDir;
    o3tl::optional<OUString>                  m_xUserDir;
};

} // namespace comphelper
diff --git a/compilerplugins/clang/constantparam.numbers.results b/compilerplugins/clang/constantparam.numbers.results
index 84b1951..ef6f9ae 100644
--- a/compilerplugins/clang/constantparam.numbers.results
+++ b/compilerplugins/clang/constantparam.numbers.results
@@ -2675,7 +2675,7 @@ slideshow/source/engine/transitions/checkerboardwipe.hxx:36
    int unitsPerEdge
    10
slideshow/source/engine/transitions/combtransition.hxx:42
    void slideshow::internal::CombTransition::CombTransition(const class boost::optional<class std::shared_ptr<class slideshow::internal::Slide> > &,const class std::shared_ptr<class slideshow::internal::Slide> &,const class std::shared_ptr<class slideshow::internal::SoundPlayer> &,const class slideshow::internal::UnoViewContainer &,class slideshow::internal::ScreenUpdater &,class slideshow::internal::EventMultiplexer &,const class basegfx::B2DVector &,int)
    void slideshow::internal::CombTransition::CombTransition(const class o3tl::optional<class std::shared_ptr<class slideshow::internal::Slide> > &,const class std::shared_ptr<class slideshow::internal::Slide> &,const class std::shared_ptr<class slideshow::internal::SoundPlayer> &,const class slideshow::internal::UnoViewContainer &,class slideshow::internal::ScreenUpdater &,class slideshow::internal::EventMultiplexer &,const class basegfx::B2DVector &,int)
    int nNumStripes
    24
slideshow/source/engine/transitions/snakewipe.hxx:55
diff --git a/compilerplugins/clang/store/stylepolice.cxx b/compilerplugins/clang/store/stylepolice.cxx
index e70b74b..87a9e44 100644
--- a/compilerplugins/clang/store/stylepolice.cxx
+++ b/compilerplugins/clang/store/stylepolice.cxx
@@ -111,7 +111,7 @@ bool StylePolice::VisitVarDecl(const VarDecl * varDecl)
    if (!qt->isPointerType() && !qt->isArrayType() && !qt->isFunctionPointerType() && !qt->isMemberPointerType()
        && matchPointerVar(name)
        && !startswith(typeName, "boost::intrusive_ptr")
        && !startswith(typeName, "boost::optional")
        && !startswith(typeName, "o3tl::optional")
        && !startswith(typeName, "boost::shared_ptr")
        && !startswith(typeName, "com::sun::star::uno::Reference")
        && !startswith(typeName, "cppu::OInterfaceIteratorHelper")
diff --git a/compilerplugins/clang/unusedmethods.results b/compilerplugins/clang/unusedmethods.results
index 5ed289b..39f442e 100644
--- a/compilerplugins/clang/unusedmethods.results
+++ b/compilerplugins/clang/unusedmethods.results
@@ -533,7 +533,7 @@ include/framework/addonsoptions.hxx:219
include/i18nlangtag/languagetag.hxx:263
    enum LanguageTag::ScriptType LanguageTag::getScriptType() const
include/o3tl/any.hxx:155
    class boost::optional<const struct o3tl::detail::Void> o3tl::tryAccess(const class com::sun::star::uno::Any &)
    class o3tl::optional<const struct o3tl::detail::Void> o3tl::tryAccess(const class com::sun::star::uno::Any &)
include/o3tl/cow_wrapper.hxx:323
    type-parameter-?-? * o3tl::cow_wrapper::get()
include/o3tl/enumarray.hxx:105
@@ -1185,7 +1185,7 @@ sc/source/ui/inc/datatableview.hxx:114
sc/source/ui/inc/impex.hxx:93
     ScImportExport::ScImportExport(class ScDocument *,const class rtl::OUString &)
sc/source/ui/inc/RandomNumberGeneratorDialog.hxx:64
    void ScRandomNumberGeneratorDialog::GenerateNumbers(type-parameter-?-? &,const char *,const class boost::optional<signed char>)
    void ScRandomNumberGeneratorDialog::GenerateNumbers(type-parameter-?-? &,const char *,const class o3tl::optional<signed char>)
sc/source/ui/inc/TableFillingAndNavigationTools.hxx:121
    unsigned long DataRangeIterator::size()
sc/source/ui/inc/viewdata.hxx:410
diff --git a/connectivity/inc/pch/precompiled_dbtools.hxx b/connectivity/inc/pch/precompiled_dbtools.hxx
index 18c96b8..ea2bc6c 100644
--- a/connectivity/inc/pch/precompiled_dbtools.hxx
+++ b/connectivity/inc/pch/precompiled_dbtools.hxx
@@ -35,7 +35,7 @@
#include <string_view>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/connectivity/inc/pch/precompiled_file.hxx b/connectivity/inc/pch/precompiled_file.hxx
index 3b43197..45f4215 100644
--- a/connectivity/inc/pch/precompiled_file.hxx
+++ b/connectivity/inc/pch/precompiled_file.hxx
@@ -40,7 +40,7 @@
#include <type_traits>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.hxx b/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.hxx
index 9bb8f37..b27bca8 100644
--- a/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.hxx
+++ b/connectivity/inc/pch/precompiled_postgresql-sdbc-impl.hxx
@@ -22,7 +22,7 @@

#if PCH_LEVEL >= 1
#include <string.h>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/module.h>
diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx
index d345aec..6d539a5 100644
--- a/connectivity/source/commontools/dbmetadata.cxx
+++ b/connectivity/source/commontools/dbmetadata.cxx
@@ -39,7 +39,7 @@
#include <sal/macros.h>
#include <sal/log.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>


namespace dbtools
@@ -72,8 +72,8 @@ namespace dbtools
        Reference< XDatabaseMetaData >  xConnectionMetaData;
        ::connectivity::DriversConfig   aDriverConfig;

        ::boost::optional< OUString >    sCachedIdentifierQuoteString;
        ::boost::optional< OUString >    sCachedCatalogSeparator;
        ::o3tl::optional< OUString >    sCachedIdentifierQuoteString;
        ::o3tl::optional< OUString >    sCachedCatalogSeparator;

        DatabaseMetaData_Impl()
            :xConnection()
@@ -155,7 +155,7 @@ namespace dbtools


        const OUString& lcl_getConnectionStringSetting(
            const DatabaseMetaData_Impl& _metaData, ::boost::optional< OUString >& _cachedSetting,
            const DatabaseMetaData_Impl& _metaData, ::o3tl::optional< OUString >& _cachedSetting,
            OUString (SAL_CALL XDatabaseMetaData::*_getter)() )
        {
            if ( !_cachedSetting )
diff --git a/connectivity/source/inc/java/io/Reader.hxx b/connectivity/source/inc/java/io/Reader.hxx
index 592d476..45d67bb 100644
--- a/connectivity/source/inc/java/io/Reader.hxx
+++ b/connectivity/source/inc/java/io/Reader.hxx
@@ -23,7 +23,7 @@
#include <java/lang/Object.hxx>
#include <cppuhelper/implbase.hxx>
#include <com/sun/star/io/XInputStream.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace connectivity
{
@@ -36,7 +36,7 @@ namespace connectivity
    // static Data for the Class
        static jclass theClass;
        virtual ~java_io_Reader() override;
        boost::optional<char> m_buf;
        o3tl::optional<char> m_buf;
    public:
        virtual jclass getMyClass() const override;
        // a Constructor, that is needed for when Returning the Object is needed:
diff --git a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx
index cb75acf..557a9c6 100644
--- a/cppcanvas/inc/pch/precompiled_cppcanvas.hxx
+++ b/cppcanvas/inc/pch/precompiled_cppcanvas.hxx
@@ -41,7 +41,7 @@
#include <type_traits>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/cppcanvas/source/inc/canvasgraphichelper.hxx b/cppcanvas/source/inc/canvasgraphichelper.hxx
index 1a61366..48e0b9c 100644
--- a/cppcanvas/source/inc/canvasgraphichelper.hxx
+++ b/cppcanvas/source/inc/canvasgraphichelper.hxx
@@ -26,7 +26,7 @@
#include <cppcanvas/canvasgraphic.hxx>
#include <cppcanvas/canvas.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace com { namespace sun { namespace star { namespace rendering
{
@@ -62,7 +62,7 @@ namespace cppcanvas
        private:
            mutable css::rendering::RenderState                                   maRenderState;

            boost::optional<basegfx::B2DPolyPolygon>                              maClipPolyPolygon;
            o3tl::optional<basegfx::B2DPolyPolygon>                              maClipPolyPolygon;
            CanvasSharedPtr                                                       mpCanvas;
        };

diff --git a/cppcanvas/source/wrapper/implcanvas.hxx b/cppcanvas/source/wrapper/implcanvas.hxx
index e509e99..a75b853 100644
--- a/cppcanvas/source/wrapper/implcanvas.hxx
+++ b/cppcanvas/source/wrapper/implcanvas.hxx
@@ -24,7 +24,7 @@
#include <com/sun/star/rendering/ViewState.hpp>
#include <cppcanvas/canvas.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>


@@ -77,7 +77,7 @@ namespace cppcanvas

        private:
            mutable css::rendering::ViewState                    maViewState;
            boost::optional<basegfx::B2DPolyPolygon>             maClipPolyPolygon;
            o3tl::optional<basegfx::B2DPolyPolygon>             maClipPolyPolygon;
            const css::uno::Reference< css::rendering::XCanvas > mxCanvas;
        };

diff --git a/cui/inc/pch/precompiled_cui.hxx b/cui/inc/pch/precompiled_cui.hxx
index 23fd2f4..77f5ecf 100644
--- a/cui/inc/pch/precompiled_cui.hxx
+++ b/cui/inc/pch/precompiled_cui.hxx
@@ -49,7 +49,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/cui/source/options/fontsubs.cxx b/cui/source/options/fontsubs.cxx
index 20baf82..95313e1 100644
--- a/cui/source/options/fontsubs.cxx
+++ b/cui/source/options/fontsubs.cxx
@@ -180,7 +180,7 @@ bool  SvxFontSubstTabPage::FillItemSet( SfxItemSet* )
    if (m_xFontNameLB->get_active() != -1)
        sFontName = m_xFontNameLB->get_active_text();
    officecfg::Office::Common::Font::SourceViewFont::FontName::set(
        boost::optional< OUString >(sFontName), batch);
        o3tl::optional< OUString >(sFontName), batch);
    batch->commit();

    return false;
diff --git a/cui/source/options/tsaurls.cxx b/cui/source/options/tsaurls.cxx
index a010afc..6fc5ad5 100644
--- a/cui/source/options/tsaurls.cxx
+++ b/cui/source/options/tsaurls.cxx
@@ -35,7 +35,7 @@ TSAURLsDialog::TSAURLsDialog(weld::Window* pParent)

    try
    {
        boost::optional<css::uno::Sequence<OUString>> aUserSetTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get());
        o3tl::optional<css::uno::Sequence<OUString>> aUserSetTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get());
        if (aUserSetTSAURLs)
        {
            const css::uno::Sequence<OUString>& rUserSetTSAURLs = *aUserSetTSAURLs;
diff --git a/dbaccess/inc/pch/precompiled_dba.hxx b/dbaccess/inc/pch/precompiled_dba.hxx
index 87dba28..4964fa3 100644
--- a/dbaccess/inc/pch/precompiled_dba.hxx
+++ b/dbaccess/inc/pch/precompiled_dba.hxx
@@ -44,7 +44,7 @@
#include <type_traits>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/dbaccess/inc/pch/precompiled_dbaxml.hxx b/dbaccess/inc/pch/precompiled_dbaxml.hxx
index 2acaefa5..5c0bdcc 100644
--- a/dbaccess/inc/pch/precompiled_dbaxml.hxx
+++ b/dbaccess/inc/pch/precompiled_dbaxml.hxx
@@ -27,7 +27,7 @@
#include <memory>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/dbaccess/inc/pch/precompiled_dbu.hxx b/dbaccess/inc/pch/precompiled_dbu.hxx
index 63b108a..9a8df0d 100644
--- a/dbaccess/inc/pch/precompiled_dbu.hxx
+++ b/dbaccess/inc/pch/precompiled_dbu.hxx
@@ -34,7 +34,7 @@
#include <string_view>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/dbaccess/source/core/api/FilteredContainer.cxx b/dbaccess/source/core/api/FilteredContainer.cxx
index 3cc33cf..4a25d4c 100644
--- a/dbaccess/source/core/api/FilteredContainer.cxx
+++ b/dbaccess/source/core/api/FilteredContainer.cxx
@@ -28,7 +28,7 @@
#include <connectivity/dbtools.hxx>
#include <tools/wldcrd.hxx>
#include <tools/diagnose_ex.h>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <sal/log.hxx>

namespace dbaccess
@@ -99,7 +99,7 @@ static sal_Int32 createWildCardVector(Sequence< OUString >& _rTableFilter, std::
        return bFilterMatch;
    }

    typedef ::boost::optional< OUString >    OptionalString;
    typedef ::o3tl::optional< OUString >    OptionalString;

    namespace {

diff --git a/dbaccess/source/core/api/resultcolumn.cxx b/dbaccess/source/core/api/resultcolumn.cxx
index ea2e1d26..93b4ba1 100644
--- a/dbaccess/source/core/api/resultcolumn.cxx
+++ b/dbaccess/source/core/api/resultcolumn.cxx
@@ -165,7 +165,7 @@ void OResultColumn::disposing()
namespace
{
    template< typename T >
    void obtain( Any& _out_rValue, ::boost::optional< T > & _rCache, const sal_Int32 _nPos, const Reference < XResultSetMetaData >& _rxResultMeta, T (SAL_CALL XResultSetMetaData::*Getter)( sal_Int32 ) )
    void obtain( Any& _out_rValue, ::o3tl::optional< T > & _rCache, const sal_Int32 _nPos, const Reference < XResultSetMetaData >& _rxResultMeta, T (SAL_CALL XResultSetMetaData::*Getter)( sal_Int32 ) )
    {
        if ( !_rCache )
            _rCache = (_rxResultMeta.get()->*Getter)(_nPos);
diff --git a/dbaccess/source/core/api/resultcolumn.hxx b/dbaccess/source/core/api/resultcolumn.hxx
index 4900f9b..4897e12 100644
--- a/dbaccess/source/core/api/resultcolumn.hxx
+++ b/dbaccess/source/core/api/resultcolumn.hxx
@@ -23,7 +23,7 @@
#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
#include <column.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <comphelper/proparrhlp.hxx>
namespace dbaccess
{
@@ -38,20 +38,20 @@ namespace dbaccess
        css::uno::Reference< css::sdbc::XDatabaseMetaData >   m_xDBMetaData;
        sal_Int32                             m_nPos;
        css::uno::Any                         m_aIsRowVersion;
        mutable ::boost::optional< sal_Bool > m_isSigned;
        mutable ::boost::optional< sal_Bool > m_isCurrency;
        mutable ::boost::optional< sal_Bool > m_bSearchable;
        mutable ::boost::optional< sal_Bool > m_isCaseSensitive;
        mutable ::boost::optional< sal_Bool > m_isReadOnly;
        mutable ::boost::optional< sal_Bool > m_isWritable;
        mutable ::boost::optional< sal_Bool > m_isDefinitelyWritable;
        mutable ::boost::optional< sal_Bool > m_isAutoIncrement;
        mutable ::boost::optional< sal_Int32 > m_isNullable;
        mutable ::boost::optional< OUString > m_sColumnLabel;
        mutable ::boost::optional< sal_Int32 > m_nColumnDisplaySize;
        mutable ::boost::optional< sal_Int32 > m_nColumnType;
        mutable ::boost::optional< sal_Int32 > m_nPrecision;
        mutable ::boost::optional< sal_Int32 > m_nScale;
        mutable ::o3tl::optional< sal_Bool > m_isSigned;
        mutable ::o3tl::optional< sal_Bool > m_isCurrency;
        mutable ::o3tl::optional< sal_Bool > m_bSearchable;
        mutable ::o3tl::optional< sal_Bool > m_isCaseSensitive;
        mutable ::o3tl::optional< sal_Bool > m_isReadOnly;
        mutable ::o3tl::optional< sal_Bool > m_isWritable;
        mutable ::o3tl::optional< sal_Bool > m_isDefinitelyWritable;
        mutable ::o3tl::optional< sal_Bool > m_isAutoIncrement;
        mutable ::o3tl::optional< sal_Int32 > m_isNullable;
        mutable ::o3tl::optional< OUString > m_sColumnLabel;
        mutable ::o3tl::optional< sal_Int32 > m_nColumnDisplaySize;
        mutable ::o3tl::optional< sal_Int32 > m_nColumnType;
        mutable ::o3tl::optional< sal_Int32 > m_nPrecision;
        mutable ::o3tl::optional< sal_Int32 > m_nScale;

        virtual ~OResultColumn() override;
    public:
diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx
index 511cc01..1530618 100644
--- a/dbaccess/source/core/dataaccess/documentdefinition.cxx
+++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx
@@ -131,7 +131,7 @@ namespace DatabaseObject = sdb::application::DatabaseObject;
namespace dbaccess
{

    typedef ::boost::optional< bool > optional_bool;
    typedef ::o3tl::optional< bool > optional_bool;

    // helper
    namespace
@@ -790,7 +790,7 @@ Any ODocumentDefinition::onCommandOpenSomething( const Any& _rOpenArgument, cons
    if ( xHandler.is() )
        aDocumentArgs.put( "InteractionHandler", xHandler );

    ::boost::optional< sal_Int16 > aDocumentMacroMode;
    ::o3tl::optional< sal_Int16 > aDocumentMacroMode;

    if ( !lcl_extractOpenMode( _rOpenArgument, nOpenMode ) )
    {
diff --git a/dbaccess/source/core/inc/ContentHelper.hxx b/dbaccess/source/core/inc/ContentHelper.hxx
index 93290fd..2ca3a32 100644
--- a/dbaccess/source/core/inc/ContentHelper.hxx
+++ b/dbaccess/source/core/inc/ContentHelper.hxx
@@ -51,7 +51,7 @@ namespace dbaccess
    struct ContentProperties
    {
        OUString aTitle;         // Title
        ::boost::optional< OUString >
        ::o3tl::optional< OUString >
                        aContentType;   // ContentType (aka MediaType aka MimeType)
        bool        bIsDocument;    // IsDocument
        bool        bIsFolder;      // IsFolder
diff --git a/dbaccess/source/core/inc/ModelImpl.hxx b/dbaccess/source/core/inc/ModelImpl.hxx
index e938cf8..446b795 100644
--- a/dbaccess/source/core/inc/ModelImpl.hxx
+++ b/dbaccess/source/core/inc/ModelImpl.hxx
@@ -166,7 +166,7 @@ private:
    oslInterlockedCount                                 m_refCount;

    /// do we have any object (forms/reports) which contains macros?
    ::boost::optional< EmbeddedMacros >                 m_aEmbeddedMacros;
    ::o3tl::optional< EmbeddedMacros >                 m_aEmbeddedMacros;

    /// true if setting the Modified flag of the document is currently locked
    bool                                                m_bModificationLock;
diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx
index 43a199f..d88d0fa 100644
--- a/dbaccess/source/filter/xml/xmlExport.cxx
+++ b/dbaccess/source/filter/xml/xmlExport.cxx
@@ -55,7 +55,7 @@
#include <connectivity/DriversConfig.hxx>
#include <connectivity/dbtools.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <memory>
#include <iterator>

@@ -350,7 +350,7 @@ void ODBExport::exportDataSource()
            {
                const OUString                       sPropertyName;
                const XMLTokenEnum                          eAttributeToken;
                const ::boost::optional< OUString >  aXMLDefault;
                const ::o3tl::optional< OUString >  aXMLDefault;

                PropertyMap( const OUString& _rPropertyName, const XMLTokenEnum _eToken )
                    :sPropertyName( _rPropertyName )
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx
index df35c9a..aceaec2 100644
--- a/dbaccess/source/ui/app/AppController.cxx
+++ b/dbaccess/source/ui/app/AppController.cxx
@@ -393,7 +393,7 @@ void SAL_CALL OApplicationController::disposing()
                            aURL.GetURLNoPass( INetURLObject::DecodeMechanism::NONE ),
                            aFilter,
                            getStrippedDatabaseName(),
                            boost::none);
                            o3tl::nullopt);

                    // add to recent document list
                    if ( aURL.GetProtocol() == INetProtocol::File )
diff --git a/dbaccess/source/ui/app/AppController.hxx b/dbaccess/source/ui/app/AppController.hxx
index 2aacb41..5039a97 100644
--- a/dbaccess/source/ui/app/AppController.hxx
+++ b/dbaccess/source/ui/app/AppController.hxx
@@ -349,7 +349,7 @@ namespace dbaui
        /** verifies the object type denotes a valid DatabaseObject, and the object name denotes an existing
            object of this type. Throws if not.
        */
        void    impl_validateObjectTypeAndName_throw( const sal_Int32 _nObjectType, const ::boost::optional< OUString >& i_rObjectName );
        void    impl_validateObjectTypeAndName_throw( const sal_Int32 _nObjectType, const ::o3tl::optional< OUString >& i_rObjectName );

    protected:
        // initializing members
diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx
index 842a48c..9c2ad5d 100644
--- a/dbaccess/source/ui/app/AppControllerGen.cxx
+++ b/dbaccess/source/ui/app/AppControllerGen.cxx
@@ -378,7 +378,7 @@ namespace
    }
}

void OApplicationController::impl_validateObjectTypeAndName_throw( const sal_Int32 _nObjectType, const ::boost::optional< OUString >& i_rObjectName )
void OApplicationController::impl_validateObjectTypeAndName_throw( const sal_Int32 _nObjectType, const ::o3tl::optional< OUString >& i_rObjectName )
{
    // ensure we're connected
    if ( !isConnected() )
@@ -460,7 +460,7 @@ Reference< XComponent > SAL_CALL OApplicationController::createComponentWithArgu
    SolarMutexGuard aSolarGuard;
    ::osl::MutexGuard aGuard( getMutex() );

    impl_validateObjectTypeAndName_throw( i_nObjectType, ::boost::optional< OUString >() );
    impl_validateObjectTypeAndName_throw( i_nObjectType, ::o3tl::optional< OUString >() );

    Reference< XComponent > xComponent( newElement(
        lcl_objectType2ElementType( i_nObjectType ),
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index c72d3a0..2b33bd6 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -3172,7 +3172,7 @@ void SbaTableQueryBrowser::impl_initialize()

    if ( m_bEnableBrowser )
    {
        m_aDocScriptSupport = ::boost::optional< bool >( false );
        m_aDocScriptSupport = ::o3tl::optional< bool >( false );
    }
    else
    {
@@ -3180,7 +3180,7 @@ void SbaTableQueryBrowser::impl_initialize()
        // there is a specific database document which we belong to.
        Reference< XOfficeDatabaseDocument > xDocument( getDataSourceOrModel(
            lcl_getDataSource( m_xDatabaseContext, sInitialDataSourceName, xConnection ) ), UNO_QUERY );
        m_aDocScriptSupport = ::boost::optional< bool >( Reference< XEmbeddedScripts >( xDocument, UNO_QUERY ).is() );
        m_aDocScriptSupport = ::o3tl::optional< bool >( Reference< XEmbeddedScripts >( xDocument, UNO_QUERY ).is() );
    }

    if ( implSelect( sInitialDataSourceName, sInitialCommand, nInitialDisplayCommandType, bEscapeProcessing, xConnection, true ) )
diff --git a/dbaccess/source/ui/dlg/advancedsettings.cxx b/dbaccess/source/ui/dlg/advancedsettings.cxx
index 7271528..9bffee9 100644
--- a/dbaccess/source/ui/dlg/advancedsettings.cxx
+++ b/dbaccess/source/ui/dlg/advancedsettings.cxx
@@ -203,7 +203,7 @@ namespace dbaui

            bool bTriState = false;

            boost::optional<bool> aValue;
            o3tl::optional<bool> aValue;

            const SfxPoolItem* pItem = _rSet.GetItem<SfxPoolItem>(booleanSetting.nItemId);
            if (const SfxBoolItem *pBoolItem = dynamic_cast<const SfxBoolItem*>( pItem) )
diff --git a/dbaccess/source/ui/dlg/optionalboolitem.hxx b/dbaccess/source/ui/dlg/optionalboolitem.hxx
index f80dcd5..ce0a8f0 100644
--- a/dbaccess/source/ui/dlg/optionalboolitem.hxx
+++ b/dbaccess/source/ui/dlg/optionalboolitem.hxx
@@ -22,7 +22,7 @@

#include <svl/poolitem.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace dbaui
{
@@ -30,7 +30,7 @@ namespace dbaui
    // OptionalBoolItem
    class OptionalBoolItem : public SfxPoolItem
    {
        ::boost::optional< bool >   m_aValue;
        ::o3tl::optional< bool >   m_aValue;

    public:
        explicit OptionalBoolItem( sal_uInt16 nWhich );
@@ -43,7 +43,7 @@ namespace dbaui
        bool    GetValue() const                { return *m_aValue; }
        void    SetValue(bool _bValue)          { m_aValue = _bValue; }

        const ::boost::optional< bool >&
        const ::o3tl::optional< bool >&
            GetFullValue() const { return m_aValue; }
    };

diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
index 48f1b52..77e6215 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -108,7 +108,7 @@ namespace dbaui
        bool                m_bShowMenu;            // if sal_True the menu should be visible otherwise not
        bool                m_bInSuspend;
        bool                m_bEnableBrowser;
        ::boost::optional< bool >
        ::o3tl::optional< bool >
                                m_aDocScriptSupport;    // relevant if and only if we are associated with exactly one DBDoc

        virtual OUString getPrivateTitle( ) const override;
diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
index 7f7163a..9950cbd 100644
--- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
+++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx
@@ -123,7 +123,7 @@ namespace dbaui
    struct DBSubComponentController_Impl
    {
    private:
        ::boost::optional< bool >       m_aDocScriptSupport;
        ::o3tl::optional< bool >       m_aDocScriptSupport;

    public:
        ::dbtools::SQLExceptionInfo     m_aCurrentError;
@@ -166,7 +166,7 @@ namespace dbaui
        {
            OSL_PRECOND( !m_aDocScriptSupport,
                "DBSubComponentController_Impl::setDocumentScriptSupport: already initialized!" );
            m_aDocScriptSupport = ::boost::optional< bool >( _bSupport );
            m_aDocScriptSupport = ::o3tl::optional< bool >( _bSupport );
        }
    };

diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 817945c..2fc67ab 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -20,7 +20,7 @@
#ifndef INCLUDED_DESKTOP_INC_APP_HXX
#define INCLUDED_DESKTOP_INC_APP_HXX

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <sal/log.hxx>
#include <vcl/svapp.hxx>
@@ -175,7 +175,7 @@ class Desktop : public Application
};

OUString GetURL_Impl(
    const OUString& rName, boost::optional< OUString > const & cwdUrl );
    const OUString& rName, o3tl::optional< OUString > const & cwdUrl );

OUString ReplaceStringHookProc(const OUString& rStr);

diff --git a/desktop/inc/pch/precompiled_deployment.hxx b/desktop/inc/pch/precompiled_deployment.hxx
index f6fbcba..667e9e5 100644
--- a/desktop/inc/pch/precompiled_deployment.hxx
+++ b/desktop/inc/pch/precompiled_deployment.hxx
@@ -27,7 +27,7 @@
#include <ostream>
#include <unordered_map>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/desktop/inc/pch/precompiled_deploymentgui.hxx b/desktop/inc/pch/precompiled_deploymentgui.hxx
index e1ad0a5..9940365 100644
--- a/desktop/inc/pch/precompiled_deploymentgui.hxx
+++ b/desktop/inc/pch/precompiled_deploymentgui.hxx
@@ -37,7 +37,7 @@
#include <string>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/conditn.hxx>
diff --git a/desktop/inc/pch/precompiled_deploymentmisc.hxx b/desktop/inc/pch/precompiled_deploymentmisc.hxx
index 3cf05ba..703c029 100644
--- a/desktop/inc/pch/precompiled_deploymentmisc.hxx
+++ b/desktop/inc/pch/precompiled_deploymentmisc.hxx
@@ -29,7 +29,7 @@
#include <string>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/desktop/inc/pch/precompiled_sofficeapp.hxx b/desktop/inc/pch/precompiled_sofficeapp.hxx
index 9428ba1..87bcfaf 100644
--- a/desktop/inc/pch/precompiled_sofficeapp.hxx
+++ b/desktop/inc/pch/precompiled_sofficeapp.hxx
@@ -44,7 +44,7 @@
#include <type_traits>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/desktop/qa/desktop_app/test_desktop_app.cxx b/desktop/qa/desktop_app/test_desktop_app.cxx
index ef88ae4..9a1b946 100644
--- a/desktop/qa/desktop_app/test_desktop_app.cxx
+++ b/desktop/qa/desktop_app/test_desktop_app.cxx
@@ -49,7 +49,7 @@ class TestSupplier : public desktop::CommandLineArgs::Supplier {
public:
    explicit TestSupplier(const std::initializer_list<OUString>& args) : m_args(args) {}

    virtual boost::optional< OUString > getCwdUrl() override { return boost::optional< OUString >(); }
    virtual o3tl::optional< OUString > getCwdUrl() override { return o3tl::optional< OUString >(); }
    virtual bool next(OUString * argument) override {
        CPPUNIT_ASSERT(argument != nullptr);
        if (m_index < m_args.size()) {
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index f448d6e..4afbed2 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2216,7 +2216,7 @@ void Desktop::OpenDefault()


OUString GetURL_Impl(
    const OUString& rName, boost::optional< OUString > const & cwdUrl )
    const OUString& rName, o3tl::optional< OUString > const & cwdUrl )
{
    // if rName is a vnd.sun.star.script URL do not attempt to parse it
    // as INetURLObj does not handle URLs there
diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx
index c395e6d..f66e814 100644
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -85,7 +85,7 @@ public:
        }
    }

    virtual boost::optional< OUString > getCwdUrl() override { return m_cwdUrl; }
    virtual o3tl::optional< OUString > getCwdUrl() override { return m_cwdUrl; }

    virtual bool next(OUString * argument) override {
        OSL_ASSERT(argument != nullptr);
@@ -98,7 +98,7 @@ public:
    }

private:
    boost::optional< OUString > m_cwdUrl;
    o3tl::optional< OUString > m_cwdUrl;
    sal_uInt32 m_count;
    sal_uInt32 m_index;
};
diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx
index 94600ed..6c18bda3 100644
--- a/desktop/source/app/cmdlineargs.hxx
+++ b/desktop/source/app/cmdlineargs.hxx
@@ -25,7 +25,7 @@
#include <vector>

#include <rtl/ustring.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace desktop
{
@@ -46,7 +46,7 @@ class CommandLineArgs
            };

            virtual ~Supplier();
            virtual boost::optional< OUString > getCwdUrl() = 0;
            virtual o3tl::optional< OUString > getCwdUrl() = 0;
            virtual bool next(OUString * argument) = 0;
        };

@@ -56,7 +56,7 @@ class CommandLineArgs
        CommandLineArgs(const CommandLineArgs&) = delete;
        const CommandLineArgs& operator=(const CommandLineArgs&) = delete;

        const boost::optional< OUString >& getCwdUrl() const { return m_cwdUrl; }
        const o3tl::optional< OUString >& getCwdUrl() const { return m_cwdUrl; }

        // Access to bool parameters
        bool                IsMinimized() const { return m_minimized;}
@@ -127,7 +127,7 @@ class CommandLineArgs
        void                    ParseCommandLine_Impl( Supplier& supplier );
        void                    InitParamValues();

        boost::optional< OUString > m_cwdUrl;
        o3tl::optional< OUString > m_cwdUrl;

        bool m_minimized;
        bool m_invisible;
diff --git a/desktop/source/app/dispatchwatcher.hxx b/desktop/source/app/dispatchwatcher.hxx
index 2b683ff..103b882 100644
--- a/desktop/source/app/dispatchwatcher.hxx
+++ b/desktop/source/app/dispatchwatcher.hxx
@@ -60,7 +60,7 @@ class DispatchWatcher : public ::cppu::WeakImplHelper< css::frame::XDispatchResu
        {
            RequestType aRequestType;
            OUString    aURL;
            boost::optional< OUString > aCwdUrl;
            o3tl::optional< OUString > aCwdUrl;
            OUString    aPrinterName;  // also conversion params
            OUString    aPreselectedFactory;
        };
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 5a79206..0461765 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -141,7 +141,7 @@ public:
        }
    }

    virtual boost::optional< OUString > getCwdUrl() override { return m_cwdUrl; }
    virtual o3tl::optional< OUString > getCwdUrl() override { return m_cwdUrl; }

    virtual bool next(OUString * argument) override { return next(argument, true); }

@@ -195,7 +195,7 @@ private:
        }
    }

    boost::optional< OUString > m_cwdUrl;
    o3tl::optional< OUString > m_cwdUrl;
    OString m_input;
    sal_Int32 m_index;
};
@@ -671,7 +671,7 @@ void RequestHandler::EnableRequests()
            pGlobal->mState = State::RequestsEnabled;
        }
        // hit the compiler over the head
        ProcessDocumentsRequest aEmptyReq { boost::optional< OUString >() };
        ProcessDocumentsRequest aEmptyReq { o3tl::optional< OUString >() };
        // trigger already queued requests
        RequestHandler::ExecuteCmdLineRequests(aEmptyReq, true);
    }
@@ -1224,7 +1224,7 @@ void PipeIpcThread::execute()

static void AddToDispatchList(
    std::vector<DispatchWatcher::DispatchRequest>& rDispatchList,
    boost::optional< OUString > const & cwdUrl,
    o3tl::optional< OUString > const & cwdUrl,
    std::vector< OUString > const & aRequestList,
    DispatchWatcher::RequestType nType,
    const OUString& aParam,
@@ -1238,7 +1238,7 @@ static void AddToDispatchList(

static void AddConversionsToDispatchList(
    std::vector<DispatchWatcher::DispatchRequest>& rDispatchList,
    boost::optional< OUString > const & cwdUrl,
    o3tl::optional< OUString > const & cwdUrl,
    std::vector< OUString > const & rRequestList,
    const OUString& rParam,
    const OUString& rPrinterName,
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index ca2533e..79b550e 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -34,7 +34,7 @@
#include <cppuhelper/implbase.hxx>
#include <osl/conditn.hxx>
#include <salhelper/thread.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace desktop
{
@@ -45,10 +45,10 @@ oslSignalAction SalMainPipeExchangeSignal_impl(void* /*pData*/, oslSignalInfo* p
// that was given by command line or by IPC pipe communication.
struct ProcessDocumentsRequest
{
    explicit ProcessDocumentsRequest(boost::optional< OUString > const & cwdUrl):
    explicit ProcessDocumentsRequest(o3tl::optional< OUString > const & cwdUrl):
        aCwdUrl(cwdUrl), pcProcessed( nullptr ), bTextCat( false ), bScriptCat( false ) {}

    boost::optional< OUString > aCwdUrl;
    o3tl::optional< OUString > aCwdUrl;
    OUString aModule;
    std::vector< OUString > aOpenList; // Documents that should be opened in the default way
    std::vector< OUString > aViewList; // Documents that should be opened in viewmode
diff --git a/desktop/source/app/opencl.cxx b/desktop/source/app/opencl.cxx
index 5ef73dd..766ac50 100644
--- a/desktop/source/app/opencl.cxx
+++ b/desktop/source/app/opencl.cxx
@@ -227,7 +227,7 @@ void Desktop::CheckOpenCLCompute(const Reference< XDesktop2 > &xDesktop)
    {
        // OpenCL device changed - sanity check it and disable if bad.

        boost::optional<sal_Int32> nOrigMinimumSize = officecfg::Office::Calc::Formula::Calculation::OpenCLMinimumDataSize::get();
        o3tl::optional<sal_Int32> nOrigMinimumSize = officecfg::Office::Calc::Formula::Calculation::OpenCLMinimumDataSize::get();
        { // set the minimum group size to something small for quick testing.
            std::shared_ptr<comphelper::ConfigurationChanges> xBatch(comphelper::ConfigurationChanges::create());
            officecfg::Office::Calc::Formula::Calculation::OpenCLMinimumDataSize::set(3 /* small */, xBatch);
diff --git a/desktop/source/deployment/dp_log.cxx b/desktop/source/deployment/dp_log.cxx
index 000dc46..9f962f0 100644
--- a/desktop/source/deployment/dp_log.cxx
+++ b/desktop/source/deployment/dp_log.cxx
@@ -36,7 +36,7 @@
#include <com/sun/star/io/IOException.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include <stdio.h>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx
index fbcb4ed..641ba62 100644
--- a/desktop/source/deployment/gui/dp_gui_service.cxx
+++ b/desktop/source/deployment/gui/dp_gui_service.cxx
@@ -36,7 +36,7 @@
#include <com/sun/star/task/XJobExecutor.hpp>
#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include "license_dialog.hxx"
#include "dp_gui_dialog2.hxx"
#include "dp_gui_extensioncmdqueue.hxx"
@@ -143,8 +143,8 @@ class ServiceImpl
                                     task::XJobExecutor>
{
    Reference<XComponentContext> const m_xComponentContext;
    boost::optional< Reference<awt::XWindow> > /* const */ m_parent;
    boost::optional<OUString> m_extensionURL;
    o3tl::optional< Reference<awt::XWindow> > /* const */ m_parent;
    o3tl::optional<OUString> m_extensionURL;
    OUString m_initialTitle;
    bool m_bShowUpdateOnly;

@@ -169,8 +169,8 @@ ServiceImpl::ServiceImpl( Sequence<Any> const& args,
      m_bShowUpdateOnly( false )
{
    /* if true then this service is running in a unopkg process and not in an office process */
    boost::optional<sal_Bool> unopkg;
    boost::optional<OUString> view;
    o3tl::optional<sal_Bool> unopkg;
    o3tl::optional<OUString> view;
    try {
        comphelper::unwrapArgs( args, m_parent, view, unopkg );
        return;
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
index c68fab0..0dcbf64 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
@@ -27,7 +27,7 @@
#include <vector>


#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/awt/WindowAttribute.hpp>
#include <com/sun/star/awt/WindowClass.hpp>
@@ -412,7 +412,7 @@ void UpdateDialog::Thread::prepareUpdateData(
        out_du.unsatisfiedDependencies[i] = dp_misc::Dependencies::getErrorText(ds[i]);
    }

    const ::boost::optional< OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL());
    const ::o3tl::optional< OUString> updateWebsiteURL(infoset.getLocalizedUpdateWebsiteURL());

    out_du.name = getUpdateDisplayString(out_data, infoset.getVersion());

@@ -841,7 +841,7 @@ bool UpdateDialog::isIgnoredUpdate( UpdateDialog::Index * index )
        {
            DisabledUpdate &rData = m_disabledUpdates[ index->m_nIndex ];
            dp_misc::DescriptionInfoset aInfoset( m_context, rData.aUpdateInfo );
            ::boost::optional< OUString > aID( aInfoset.getIdentifier() );
            ::o3tl::optional< OUString > aID( aInfoset.getIdentifier() );
            if ( aID )
                aExtensionID = *aID;
            aVersion = aInfoset.getVersion();
diff --git a/desktop/source/deployment/inc/dp_descriptioninfoset.hxx b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx
index 9608a75..03a5ede 100644
--- a/desktop/source/deployment/inc/dp_descriptioninfoset.hxx
+++ b/desktop/source/deployment/inc/dp_descriptioninfoset.hxx
@@ -22,7 +22,7 @@

#include <sal/config.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <sal/types.h>
@@ -83,7 +83,7 @@ public:
       @return
       the identifier, or an empty <code>optional</code> if none is specified
    */
    ::boost::optional< OUString > getIdentifier() const;
    ::o3tl::optional< OUString > getIdentifier() const;

    /**
       Return the textual version representation.
@@ -135,7 +135,7 @@ public:
        As long as there is a simple-license element, the function will return
        the structure. If it does not exist, then the optional object is uninitialized.
    */
    ::boost::optional<SimpleLicenseAttributes> getSimpleLicenseAttributes() const;
    ::o3tl::optional<SimpleLicenseAttributes> getSimpleLicenseAttributes() const;

    /** returns the localized display name of the extensions.

@@ -162,7 +162,7 @@ public:
        the download website URL, or an empty <code>optional</code> if none is
        specified
    */
    ::boost::optional< OUString > getLocalizedUpdateWebsiteURL() const;
    ::o3tl::optional< OUString > getLocalizedUpdateWebsiteURL() const;

    /** returns the relative URL to the description.

@@ -206,7 +206,7 @@ public:
    bool hasDescription() const;

private:
    SAL_DLLPRIVATE ::boost::optional< OUString > getOptionalValue(
    SAL_DLLPRIVATE ::o3tl::optional< OUString > getOptionalValue(
        OUString const & expression) const;

    SAL_DLLPRIVATE css::uno::Sequence< OUString > getUrls(
diff --git a/desktop/source/deployment/inc/dp_identifier.hxx b/desktop/source/deployment/inc/dp_identifier.hxx
index 16d95c5..a7ce629 100644
--- a/desktop/source/deployment/inc/dp_identifier.hxx
+++ b/desktop/source/deployment/inc/dp_identifier.hxx
@@ -22,7 +22,7 @@

#include <sal/config.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <com/sun/star/uno/Reference.hxx>

#include "dp_misc_api.hxx"
@@ -47,7 +47,7 @@ namespace dp_misc {
   on the given file name
*/
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString generateIdentifier(
    ::boost::optional< OUString > const & optional,
    ::o3tl::optional< OUString > const & optional,
    OUString const & fileName);

/**
diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx
index fae8afe..e99dbda 100644
--- a/desktop/source/deployment/manager/dp_extensionmanager.cxx
+++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx
@@ -560,7 +560,7 @@ bool ExtensionManager::doChecksForAddExtension(
        ExtensionProperties props(OUString(), properties, Reference<ucb::XCommandEnvironment>(), m_xContext);

        dp_misc::DescriptionInfoset info(dp_misc::getDescriptionInfoset(xTmpExtension->getURL()));
        const ::boost::optional<dp_misc::SimpleLicenseAttributes> licenseAttributes =
        const ::o3tl::optional<dp_misc::SimpleLicenseAttributes> licenseAttributes =
            info.getSimpleLicenseAttributes();

        if (licenseAttributes && licenseAttributes->suppressIfRequired
diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx
index 7c79ab4..be71505 100644
--- a/desktop/source/deployment/manager/dp_manager.cxx
+++ b/desktop/source/deployment/manager/dp_manager.cxx
@@ -1391,7 +1391,7 @@ bool PackageManagerImpl::synchronizeAddedExtensions(
                    // shall the license be suppressed?
                    DescriptionInfoset info =
                        dp_misc::getDescriptionInfoset(url);
                    ::boost::optional<dp_misc::SimpleLicenseAttributes>
                    ::o3tl::optional<dp_misc::SimpleLicenseAttributes>
                          attr = info.getSimpleLicenseAttributes();
                    ExtensionProperties props(url, xCmdEnv, m_xComponentContext);
                    bool bNoLicense = false;
diff --git a/desktop/source/deployment/manager/dp_properties.hxx b/desktop/source/deployment/manager/dp_properties.hxx
index f6edd847..cc4bd93 100644
--- a/desktop/source/deployment/manager/dp_properties.hxx
+++ b/desktop/source/deployment/manager/dp_properties.hxx
@@ -23,7 +23,7 @@

#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>


namespace dp_manager {
@@ -34,8 +34,8 @@ class ExtensionProperties final
    OUString m_propFileUrl;
    const css::uno::Reference<css::ucb::XCommandEnvironment> m_xCmdEnv;
    const css::uno::Reference<css::uno::XComponentContext> m_xContext;
    ::boost::optional< OUString> m_prop_suppress_license;
    ::boost::optional< OUString> m_prop_extension_update;
    ::o3tl::optional< OUString> m_prop_suppress_license;
    ::o3tl::optional< OUString> m_prop_extension_update;

    static OUString getPropertyValue(css::beans::NamedValue const & v);
public:
diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx
index 3e10663..585fcec 100644
--- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx
+++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx
@@ -26,7 +26,7 @@
#include <comphelper/seqstream.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/deployment/DeploymentException.hpp>
@@ -327,7 +327,7 @@ DescriptionInfoset::DescriptionInfoset(

DescriptionInfoset::~DescriptionInfoset() {}

::boost::optional< OUString > DescriptionInfoset::getIdentifier() const {
::o3tl::optional< OUString > DescriptionInfoset::getIdentifier() const {
    return getOptionalValue("desc:identifier/@value");
}

@@ -347,7 +347,7 @@ OUString DescriptionInfoset::getNodeValueFromExpression(OUString const & express
void DescriptionInfoset::checkBlacklist() const
{
    if (m_element.is()) {
        boost::optional< OUString > id(getIdentifier());
        o3tl::optional< OUString > id(getIdentifier());
        if (!id)
            return; // nothing to check
        OUString currentversion(getVersion());
@@ -521,20 +521,20 @@ OUString DescriptionInfoset::getIconURL( bool bHighContrast ) const
    return OUString();
}

::boost::optional< OUString > DescriptionInfoset::getLocalizedUpdateWebsiteURL()
::o3tl::optional< OUString > DescriptionInfoset::getLocalizedUpdateWebsiteURL()
    const
{
    bool bParentExists = false;
    const OUString sURL (getLocalizedHREFAttrFromChild("/desc:description/desc:update-website", &bParentExists ));

    if (!sURL.isEmpty())
        return ::boost::optional< OUString >(sURL);
        return ::o3tl::optional< OUString >(sURL);
    else
        return bParentExists ? ::boost::optional< OUString >(OUString()) :
            ::boost::optional< OUString >();
        return bParentExists ? ::o3tl::optional< OUString >(OUString()) :
            ::o3tl::optional< OUString >();
}

::boost::optional< OUString > DescriptionInfoset::getOptionalValue(
::o3tl::optional< OUString > DescriptionInfoset::getOptionalValue(
    OUString const & expression) const
{
    css::uno::Reference< css::xml::dom::XNode > n;
@@ -546,8 +546,8 @@ OUString DescriptionInfoset::getIconURL( bool bHighContrast ) const
        }
    }
    return n.is()
        ? ::boost::optional< OUString >(getNodeValue(n))
        : ::boost::optional< OUString >();
        ? ::o3tl::optional< OUString >(getNodeValue(n))
        : ::o3tl::optional< OUString >();
}

css::uno::Sequence< OUString > DescriptionInfoset::getUrls(
@@ -632,7 +632,7 @@ OUString DescriptionInfoset::getLocalizedLicenseURL() const

}

::boost::optional<SimpleLicenseAttributes>
::o3tl::optional<SimpleLicenseAttributes>
DescriptionInfoset::getSimpleLicenseAttributes() const
{
    //Check if the node exist
@@ -649,22 +649,22 @@ DescriptionInfoset::getSimpleLicenseAttributes() const
            attributes.acceptBy =
                getNodeValueFromExpression("/desc:description/desc:registration/desc:simple-license/@accept-by");

            ::boost::optional< OUString > suppressOnUpdate = getOptionalValue("/desc:description/desc:registration/desc:simple-license/@suppress-on-update");
            ::o3tl::optional< OUString > suppressOnUpdate = getOptionalValue("/desc:description/desc:registration/desc:simple-license/@suppress-on-update");
            if (suppressOnUpdate)
                attributes.suppressOnUpdate = (*suppressOnUpdate).trim().equalsIgnoreAsciiCase("true");
            else
                attributes.suppressOnUpdate = false;

            ::boost::optional< OUString > suppressIfRequired = getOptionalValue("/desc:description/desc:registration/desc:simple-license/@suppress-if-required");
            ::o3tl::optional< OUString > suppressIfRequired = getOptionalValue("/desc:description/desc:registration/desc:simple-license/@suppress-if-required");
            if (suppressIfRequired)
                attributes.suppressIfRequired = (*suppressIfRequired).trim().equalsIgnoreAsciiCase("true");
            else
                attributes.suppressIfRequired = false;

            return ::boost::optional<SimpleLicenseAttributes>(attributes);
            return ::o3tl::optional<SimpleLicenseAttributes>(attributes);
        }
    }
    return ::boost::optional<SimpleLicenseAttributes>();
    return ::o3tl::optional<SimpleLicenseAttributes>();
}

OUString DescriptionInfoset::getLocalizedDescriptionURL() const
diff --git a/desktop/source/deployment/misc/dp_identifier.cxx b/desktop/source/deployment/misc/dp_identifier.cxx
index bb90b8b..7f07b53 100644
--- a/desktop/source/deployment/misc/dp_identifier.cxx
+++ b/desktop/source/deployment/misc/dp_identifier.cxx
@@ -20,7 +20,7 @@

#include <sal/config.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <com/sun/star/beans/Optional.hpp>
#include <com/sun/star/deployment/XPackage.hpp>
#include <com/sun/star/uno/Reference.hxx>
@@ -34,7 +34,7 @@
namespace dp_misc {

OUString generateIdentifier(
    ::boost::optional< OUString > const & optional,
    ::o3tl::optional< OUString > const & optional,
    OUString const & fileName)
{
    return optional ? *optional : generateLegacyIdentifier(fileName);
diff --git a/desktop/source/deployment/misc/dp_update.cxx b/desktop/source/deployment/misc/dp_update.cxx
index 38b37d1..1387ad0 100644
--- a/desktop/source/deployment/misc/dp_update.cxx
+++ b/desktop/source/deployment/misc/dp_update.cxx
@@ -112,7 +112,7 @@ void getOwnUpdateInfos(
                    Reference< xml::dom::XNode >(infos[j], UNO_QUERY_THROW));
                if (!infoset.hasDescription())
                    continue;
                boost::optional< OUString > result_id(infoset.getIdentifier());
                o3tl::optional< OUString > result_id(infoset.getIdentifier());
                if (!result_id)
                    continue;
                SAL_INFO( "extensions.update", "  found version "
@@ -153,7 +153,7 @@ void getDefaultUpdateInfos(
    {
        Reference< xml::dom::XNode > node(infos[i], UNO_QUERY_THROW);
        dp_misc::DescriptionInfoset infoset(xContext, node);
        boost::optional< OUString > id(infoset.getIdentifier());
        o3tl::optional< OUString > id(infoset.getIdentifier());
        if (!id) {
            continue;
        }
diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
index 40d0ee9..fb00877 100644
--- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx
+++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx
@@ -137,7 +137,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
                          Reference<XCommandEnvironment> const & xCmdEnv );
#endif
    void addDataToDb(OUString const & url, ConfigurationBackendDb::Data const & data);
    ::boost::optional<ConfigurationBackendDb::Data> readDataFromDb(OUString const & url);
    ::o3tl::optional<ConfigurationBackendDb::Data> readDataFromDb(OUString const & url);
    void revokeEntryFromDb(OUString const & url);
    bool hasActiveEntry(OUString const & url);
    bool activateEntry(OUString const & url);
@@ -247,10 +247,10 @@ void BackendImpl::addDataToDb(
        m_backendDb->addEntry(url, data);
}

::boost::optional<ConfigurationBackendDb::Data> BackendImpl::readDataFromDb(
::o3tl::optional<ConfigurationBackendDb::Data> BackendImpl::readDataFromDb(
    OUString const & url)
{
    ::boost::optional<ConfigurationBackendDb::Data> data;
    ::o3tl::optional<ConfigurationBackendDb::Data> data;
    if (m_backendDb)
        data = m_backendDb->getEntry(url);
    return data;
@@ -495,7 +495,7 @@ bool BackendImpl::removeFromConfigmgrIni(
        //url to the file in the user installation (e.g. $BUNDLED_EXTENSIONS_USER)
        //However, m_url (getURL()) contains the URL for the file in the actual
        //extension installation.
        ::boost::optional<ConfigurationBackendDb::Data> data = readDataFromDb(url_);
        ::o3tl::optional<ConfigurationBackendDb::Data> data = readDataFromDb(url_);
        if (data)
            i = std::find(rSet.begin(), rSet.end(), data->iniEntry);
    }
@@ -687,7 +687,7 @@ void BackendImpl::PackageImpl::processPackage_(
    {
        if (getMyBackend()->activateEntry(getURL()))
        {
            ::boost::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url);
            ::o3tl::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url);
            OSL_ASSERT(data);
            that->addToConfigmgrIni( m_isSchema, false, data->iniEntry, xCmdEnv );
        }
@@ -779,7 +779,7 @@ void BackendImpl::PackageImpl::processPackage_(
            }
        }
#endif
        ::boost::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url);
        ::o3tl::optional<ConfigurationBackendDb::Data> data = that->readDataFromDb(url);
        //If an xcu file was life deployed then always a data entry is written.
        //If the xcu file was already in the configmr.ini then there is also
        //a data entry
diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx
index 68a1f00..ba81597 100644
--- a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx
+++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.cxx
@@ -96,7 +96,7 @@ void ConfigurationBackendDb::addEntry(OUString const & url, Data const & data)
}


::boost::optional<ConfigurationBackendDb::Data>
::o3tl::optional<ConfigurationBackendDb::Data>
ConfigurationBackendDb::getEntry(OUString const & url)
{
    try
@@ -110,9 +110,9 @@ ConfigurationBackendDb::getEntry(OUString const & url)
        }
        else
        {
            return ::boost::optional<Data>();
            return ::o3tl::optional<Data>();
        }
        return ::boost::optional<Data>(retData);
        return ::o3tl::optional<Data>(retData);
    }
    catch ( const css::deployment::DeploymentException& )
    {
diff --git a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx
index 09cbf05..0e0d4c4 100644
--- a/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx
+++ b/desktop/source/deployment/registry/configuration/dp_configurationbackenddb.hxx
@@ -23,7 +23,7 @@
#include <rtl/ustring.hxx>
#include <rtl/string.hxx>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <dp_backenddb.hxx>

namespace com { namespace sun { namespace star {
@@ -69,7 +69,7 @@ public:

    void addEntry(OUString const & url, Data const & data);

    ::boost::optional<Data> getEntry(OUString const & url);
    ::o3tl::optional<Data> getEntry(OUString const & url);
    std::vector< OUString> getAllDataUrls();
};

diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx
index 5c7b9bd..bdab161 100644
--- a/desktop/source/deployment/registry/dp_backend.cxx
+++ b/desktop/source/deployment/registry/dp_backend.cxx
@@ -46,7 +46,7 @@
#include <com/sun/star/sdbc/XRow.hpp>
#include <tools/diagnose_ex.h>
#include <unotools/tempfile.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -83,8 +83,8 @@ PackageRegistryBackend::PackageRegistryBackend(
      m_eContext( Context::Unknown )
{
    assert(xContext.is());
    boost::optional<OUString> cachePath;
    boost::optional<bool> readOnly;
    o3tl::optional<OUString> cachePath;
    o3tl::optional<bool> readOnly;
    comphelper::unwrapArgs( args, m_context, cachePath, readOnly );
    if (cachePath)
        m_cachePath = *cachePath;
diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx
index 5d2541a..cba0ac0 100644
--- a/desktop/source/deployment/registry/help/dp_help.cxx
+++ b/desktop/source/deployment/registry/help/dp_help.cxx
@@ -42,7 +42,7 @@
#include <com/sun/star/deployment/ExtensionRemovedException.hpp>
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -99,7 +99,7 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
    void implCollectXhpFiles( const OUString& aDir,
        std::vector< OUString >& o_rXhpFileVector );

    ::boost::optional<HelpBackendDb::Data> readDataFromDb(OUString const & url);
    ::o3tl::optional<HelpBackendDb::Data> readDataFromDb(OUString const & url);
    bool hasActiveEntry(OUString const & url);
    bool activateEntry(OUString const & url);

@@ -204,10 +204,10 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
        static_cast<sal_Int16>(-1) );
}

::boost::optional<HelpBackendDb::Data> BackendImpl::readDataFromDb(
::o3tl::optional<HelpBackendDb::Data> BackendImpl::readDataFromDb(
    OUString const & url)
{
    ::boost::optional<HelpBackendDb::Data> data;
    ::o3tl::optional<HelpBackendDb::Data> data;
    if (m_backendDb)
        data = m_backendDb->getEntry(url);
    return data;
@@ -337,7 +337,7 @@ beans::Optional< OUString > BackendImpl::PackageImpl::getRegistrationDataURL()
    if (m_bRemoved)
        throw deployment::ExtensionRemovedException();

    ::boost::optional<HelpBackendDb::Data> data =
    ::o3tl::optional<HelpBackendDb::Data> data =
          getMyBackend()->readDataFromDb(getURL());

    if (data && getMyBackend()->hasActiveEntry(getURL()))
diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx
index 59867dd..7f9f709 100644
--- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx
+++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx
@@ -94,7 +94,7 @@ void HelpBackendDb::addEntry(OUString const & url, Data const & data)
}


::boost::optional<HelpBackendDb::Data>
::o3tl::optional<HelpBackendDb::Data>
HelpBackendDb::getEntry(OUString const & url)
{
    try
@@ -107,9 +107,9 @@ HelpBackendDb::getEntry(OUString const & url)
        }
        else
        {
            return ::boost::optional<Data>();
            return ::o3tl::optional<Data>();
        }
        return ::boost::optional<Data>(retData);
        return ::o3tl::optional<Data>(retData);
    }
    catch ( const css::deployment::DeploymentException& )
    {
diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx
index ad030ee..1a9eabc 100644
--- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx
+++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_REGISTRY_HELP_DP_HELPBACKENDDB_HXX

#include <rtl/ustring.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <dp_backenddb.hxx>

namespace com { namespace sun { namespace star {
@@ -64,7 +64,7 @@ public:

    void addEntry(OUString const & url, Data const & data);

    ::boost::optional<Data> getEntry(OUString const & url);
    ::o3tl::optional<Data> getEntry(OUString const & url);
    //must also return the data urls for entries with @active="false". That is,
    //those are currently revoked.
    std::vector< OUString> getAllDataUrls();
diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx
index 712742e..4ae501f 100644
--- a/desktop/source/deployment/registry/package/dp_package.cxx
+++ b/desktop/source/deployment/registry/package/dp_package.cxx
@@ -68,7 +68,7 @@
#include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
#include <com/sun/star/xml/xpath/XXPathAPI.hpp>
#include <com/sun/star/deployment/XPackageManager.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <tools/diagnose_ex.h>

#include <algorithm>
@@ -628,7 +628,7 @@ bool BackendImpl::PackageImpl::checkLicense(
{
    try
    {
        ::boost::optional<SimpleLicenseAttributes> simplLicAttr
        ::o3tl::optional<SimpleLicenseAttributes> simplLicAttr
            = info.getSimpleLicenseAttributes();
        if (! simplLicAttr)
            return true;
@@ -951,7 +951,7 @@ OUString BackendImpl::PackageImpl::getLicenseText()
    OUString sLicense;
    DescriptionInfoset aInfo = getDescriptionInfoset();

    ::boost::optional< SimpleLicenseAttributes > aSimplLicAttr = aInfo.getSimpleLicenseAttributes();
    ::o3tl::optional< SimpleLicenseAttributes > aSimplLicAttr = aInfo.getSimpleLicenseAttributes();
    if ( aSimplLicAttr )
    {
        OUString aLicenseURL = aInfo.getLocalizedLicenseURL();
diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx
index 2136e44..a6de29f 100644
--- a/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx
+++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx
@@ -22,7 +22,7 @@

#include <rtl/ustring.hxx>
#include <dp_backenddb.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace com { namespace sun { namespace star {
        namespace uno {
diff --git a/editeng/inc/editattr.hxx b/editeng/inc/editattr.hxx
index 2b74427..99faa6e 100644
--- a/editeng/inc/editattr.hxx
+++ b/editeng/inc/editattr.hxx
@@ -22,7 +22,7 @@

#include <editeng/eeitem.hxx>
#include <svl/poolitem.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <tools/color.hxx>
#include <tools/debug.hxx>

@@ -364,8 +364,8 @@ public:
class EditCharAttribField: public EditCharAttrib
{
    OUString   aFieldValue;
    boost::optional<Color>  mxTxtColor;
    boost::optional<Color>  mxFldColor;
    o3tl::optional<Color>  mxTxtColor;
    o3tl::optional<Color>  mxFldColor;

    EditCharAttribField& operator = ( const EditCharAttribField& rAttr ) = delete;

@@ -379,8 +379,8 @@ public:
                                    { return !(operator == ( rAttr ) ); }

    virtual void    SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
    boost::optional<Color>&   GetTextColor()      { return mxTxtColor; }
    boost::optional<Color>&   GetFieldColor()     { return mxFldColor; }
    o3tl::optional<Color>&   GetTextColor()      { return mxTxtColor; }
    o3tl::optional<Color>&   GetFieldColor()     { return mxFldColor; }

    const OUString& GetFieldValue() const { return aFieldValue;}
    void SetFieldValue(const OUString& rVal);
diff --git a/editeng/inc/pch/precompiled_editeng.hxx b/editeng/inc/pch/precompiled_editeng.hxx
index fb69503..391feb2 100644
--- a/editeng/inc/pch/precompiled_editeng.hxx
+++ b/editeng/inc/pch/precompiled_editeng.hxx
@@ -49,7 +49,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index e832dff..d5fb548 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -813,7 +813,7 @@ class UrlEditEngine : public EditEngine
public:
    explicit UrlEditEngine(SfxItemPool *pPool) : EditEngine(pPool) {}

    virtual OUString CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, boost::optional<Color>&, boost::optional<Color>& ) override
    virtual OUString CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, o3tl::optional<Color>&, o3tl::optional<Color>& ) override
    {
        return "jim@bob.com"; // a sophisticated view of value:
    }
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index e7faf82..2cf4d88 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -2577,7 +2577,7 @@ tools::Rectangle EditEngine::GetBulletArea( sal_Int32 )
    return tools::Rectangle( Point(), Point() );
}

OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, boost::optional<Color>&, boost::optional<Color>& )
OUString EditEngine::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, o3tl::optional<Color>&, o3tl::optional<Color>& )
{
    return OUString(' ');
}
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index 5d3db66..ee0fe79 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -61,7 +61,7 @@
#include <o3tl/deleter.hxx>
#include <o3tl/typed_flags_set.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <memory>
#include <vector>

@@ -238,7 +238,7 @@ private:
    EditEngine*               pEditEngine;
    VclPtr<vcl::Window>       pOutWin;
    EditView::OutWindowSet    aOutWindowSet;
    boost::optional<PointerStyle>  mxPointer;
    o3tl::optional<PointerStyle>  mxPointer;
    std::unique_ptr<DragAndDropInfo>  pDragAndDropInfo;

    css::uno::Reference< css::datatransfer::dnd::XDragSourceListener > mxDnDListener;
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 7e42732..cad718e 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -2514,7 +2514,7 @@ bool SvxAutoCorrectLanguageLists::MakeCombinedChanges( std::vector<SvxAutocorrWo
    {
        for (SvxAutocorrWord & aWordToDelete : aDeleteEntries)
        {
            boost::optional<SvxAutocorrWord> xFoundEntry = pAutocorr_List->FindAndRemove( &aWordToDelete );
            o3tl::optional<SvxAutocorrWord> xFoundEntry = pAutocorr_List->FindAndRemove( &aWordToDelete );
            if( xFoundEntry )
            {
                if( !xFoundEntry->IsTextOnly() )
@@ -2537,7 +2537,7 @@ bool SvxAutoCorrectLanguageLists::MakeCombinedChanges( std::vector<SvxAutocorrWo
        for (const SvxAutocorrWord & aNewEntrie : aNewEntries)
        {
            SvxAutocorrWord aWordToAdd(aNewEntrie.GetShort(), aNewEntrie.GetLong(), true );
            boost::optional<SvxAutocorrWord> xRemoved = pAutocorr_List->FindAndRemove( &aWordToAdd );
            o3tl::optional<SvxAutocorrWord> xRemoved = pAutocorr_List->FindAndRemove( &aWordToAdd );
            if( xRemoved )
            {
                if( !xRemoved->IsTextOnly() )
@@ -2583,7 +2583,7 @@ bool SvxAutoCorrectLanguageLists::PutText( const OUString& rShort, const OUStrin
    if( bRet )
    {
        SvxAutocorrWord aNew(rShort, rLong, true );
        boost::optional<SvxAutocorrWord> xRemove = pAutocorr_List->FindAndRemove( &aNew );
        o3tl::optional<SvxAutocorrWord> xRemove = pAutocorr_List->FindAndRemove( &aNew );
        if( xRemove )
        {
            if( !xRemove->IsTextOnly() )
@@ -2719,7 +2719,7 @@ bool SvxAutocorrWordList::empty() const
    return mpImpl->maHash.empty() && mpImpl->maSortedVector.empty();
}

boost::optional<SvxAutocorrWord> SvxAutocorrWordList::FindAndRemove(const SvxAutocorrWord *pWord)
o3tl::optional<SvxAutocorrWord> SvxAutocorrWordList::FindAndRemove(const SvxAutocorrWord *pWord)
{

    if ( mpImpl->maSortedVector.empty() ) // use the hash
@@ -2742,7 +2742,7 @@ boost::optional<SvxAutocorrWord> SvxAutocorrWordList::FindAndRemove(const SvxAut
            return pMatch;
        }
    }
    return boost::optional<SvxAutocorrWord>();
    return o3tl::optional<SvxAutocorrWord>();
}

// return the sorted contents - defer sorting until we have to.
diff --git a/editeng/source/outliner/outleeng.cxx b/editeng/source/outliner/outleeng.cxx
index eb9881e..fe122a9 100644
--- a/editeng/source/outliner/outleeng.cxx
+++ b/editeng/source/outliner/outleeng.cxx
@@ -169,7 +169,7 @@ void OutlinerEditEng::DrawingTab( const Point& rStartPos, long nWidth, const OUS
            bEndOfLine, bEndOfParagraph, rOverlineColor, rTextLineColor );
}

OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
OUString OutlinerEditEng::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor )
{
    return pOwner->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}
diff --git a/editeng/source/outliner/outleeng.hxx b/editeng/source/outliner/outleeng.hxx
index 5110d8b..46970c7 100644
--- a/editeng/source/outliner/outleeng.hxx
+++ b/editeng/source/outliner/outleeng.hxx
@@ -71,7 +71,7 @@ public:
    // for text conversion
    virtual bool        ConvertNextDocument() override;

    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) override;
    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor ) override;

    virtual tools::Rectangle   GetBulletArea( sal_Int32 nPara ) override;

diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 16a3833..71b3cf5 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -648,7 +648,7 @@ void Outliner::AddText( const OutlinerParaObject& rPObj, bool bAppend )
    pEditEngine->SetUpdateMode( bUpdate );
}

OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor )
{
    if ( !aCalcFieldValueHdl.IsSet() )
        return OUString( ' ' );
diff --git a/editeng/source/uno/unoedprx.cxx b/editeng/source/uno/unoedprx.cxx
index c7ac1bc..a56404c 100644
--- a/editeng/source/uno/unoedprx.cxx
+++ b/editeng/source/uno/unoedprx.cxx
@@ -618,7 +618,7 @@ SfxItemPool* SvxAccessibleTextAdapter::GetPool() const
    return mpTextForwarder->GetPool();
}

OUString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
OUString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor )
{
    assert(mpTextForwarder && "SvxAccessibleTextAdapter: no forwarder");

diff --git a/editeng/source/uno/unofored.cxx b/editeng/source/uno/unofored.cxx
index 73a4903..fb12366 100644
--- a/editeng/source/uno/unofored.cxx
+++ b/editeng/source/uno/unofored.cxx
@@ -153,7 +153,7 @@ bool SvxEditEngineForwarder::IsValid() const
    return rEditEngine.GetUpdateMode();
}

OUString SvxEditEngineForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
OUString SvxEditEngineForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor )
{
    return rEditEngine.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}
diff --git a/editeng/source/uno/unoforou.cxx b/editeng/source/uno/unoforou.cxx
index b9abddf..9fb5554 100644
--- a/editeng/source/uno/unoforou.cxx
+++ b/editeng/source/uno/unoforou.cxx
@@ -220,7 +220,7 @@ void SvxOutlinerForwarder::QuickSetAttribs( const SfxItemSet& rSet, const ESelec
    rOutliner.QuickSetAttribs( rSet, rSel );
}

OUString SvxOutlinerForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
OUString SvxOutlinerForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor )
{
    return rOutliner.CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
}
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index e0ffbfe..25d2b70c 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -634,8 +634,8 @@ void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertySimpleEntry* pM
            uno::Reference< text::XTextRange > xAnchor( this );

            // get presentation string for field
            boost::optional<Color> pTColor;
            boost::optional<Color> pFColor;
            o3tl::optional<Color> pTColor;
            o3tl::optional<Color> pFColor;

            SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
            OUString aPresentation( pForwarder->CalcFieldValue( SvxFieldItem(*pData, EE_FEATURE_FIELD), maSelection.nStartPara, maSelection.nStartPos, pTColor, pFColor ) );
@@ -2359,7 +2359,7 @@ void SvxDummyTextSource::QuickInsertLineBreak( const ESelection& )
{
};

OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, boost::optional<Color>&, boost::optional<Color>& )
OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, o3tl::optional<Color>&, o3tl::optional<Color>& )
{
    return OUString();
}
diff --git a/emfio/inc/pch/precompiled_emfio.hxx b/emfio/inc/pch/precompiled_emfio.hxx
index 047648a1..d97e3d0 100644
--- a/emfio/inc/pch/precompiled_emfio.hxx
+++ b/emfio/inc/pch/precompiled_emfio.hxx
@@ -24,7 +24,7 @@
#include <memory>
#include <stddef.h>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx
index 58c4d97..a070d8c 100644
--- a/emfio/source/reader/wmfreader.cxx
+++ b/emfio/source/reader/wmfreader.cxx
@@ -21,7 +21,7 @@
#include <emfreader.hxx>

#include <memory>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <rtl/crc.h>
#include <rtl/tencinfo.h>
#include <sal/log.hxx>
@@ -1489,10 +1489,10 @@ namespace emfio
        auto nEnd = nPos + pStm->remainingSize();

        Point aWinOrg(0,0);
        boost::optional<Size>  aWinExt;
        o3tl::optional<Size>  aWinExt;

        Point aViewportOrg(0,0);
        boost::optional<Size>  aViewportExt;
        o3tl::optional<Size>  aViewportExt;

        if (nEnd - nPos)
        {
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index a122e6a..0c39926 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -139,7 +139,7 @@
#include <svtools/embedhlp.hxx>
#include <o3tl/enumrange.hxx>
#include <o3tl/safeint.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <sal/log.hxx>

#include <algorithm>
@@ -2339,7 +2339,7 @@ SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* 
                    rOutliner.QuickSetAttribs( aPortionAttribs, aSelection );
                    aSelection.nStartPos = aSelection.nEndPos;
                }
                boost::optional< sal_Int16 > oStartNumbering;
                o3tl::optional< sal_Int16 > oStartNumbering;
                SfxItemSet aParagraphAttribs( rOutliner.GetEmptyItemSet() );
                pPara->ApplyTo( aParagraphAttribs, oStartNumbering, *this, nDestinationInstance );

@@ -3400,7 +3400,7 @@ PPTNumberFormatCreator::~PPTNumberFormatCreator()

bool PPTNumberFormatCreator::ImplGetExtNumberFormat( SdrPowerPointImport const & rManager,
    SvxNumberFormat& rNumberFormat, sal_uInt32 nLevel, TSS_Type nInstance, TSS_Type nDestinationInstance,
        boost::optional< sal_Int16 >& rStartNumbering, sal_uInt32 nFontHeight,  PPTParagraphObj const * pPara )
        o3tl::optional< sal_Int16 >& rStartNumbering, sal_uInt32 nFontHeight,  PPTParagraphObj const * pPara )
{
    bool bHardAttribute = ( nDestinationInstance == TSS_Type::Unknown );

@@ -3641,7 +3641,7 @@ bool PPTNumberFormatCreator::ImplGetExtNumberFormat( SdrPowerPointImport const &
            }
            break;
        }
        rStartNumbering = boost::optional< sal_Int16 >( nAnmScheme >> 16 );
        rStartNumbering = o3tl::optional< sal_Int16 >( nAnmScheme >> 16 );
        sal_Int16 nBuStart = *rStartNumbering;
        //The Seventh bit of nBuFlags that specifies whether fBulletHasAutoNumber exists,
        //and fBulletHasAutoNumber that specifies whether this paragraph has an automatic numbering scheme.
@@ -3669,7 +3669,7 @@ void PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport const & rManag
    nTextOfs = rParaLevel.mnTextOfs;
    nBulletOfs = rParaLevel.mnBulletOfs;

    boost::optional< sal_Int16 > oStartNumbering;
    o3tl::optional< sal_Int16 > oStartNumbering;
    ImplGetExtNumberFormat( rManager, rNumberFormat, nLevel, nInstance, TSS_Type::Unknown, oStartNumbering, rCharLevel.mnFontHeight, nullptr );
    if ( ( rNumberFormat.GetNumberingType() != SVX_NUM_BITMAP ) && ( nBulletHeight > 0x7fff ) )
        nBulletHeight = rCharLevel.mnFontHeight ? ((- static_cast<sal_Int16>(nBulletHeight)) * 100 ) / rCharLevel.mnFontHeight : 100;
@@ -3702,7 +3702,7 @@ void PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport const & rManag
}

bool PPTNumberFormatCreator::GetNumberFormat( SdrPowerPointImport const & rManager, SvxNumberFormat& rNumberFormat, PPTParagraphObj* pParaObj,
                                                TSS_Type nDestinationInstance, boost::optional< sal_Int16 >& rStartNumbering )
                                                TSS_Type nDestinationInstance, o3tl::optional< sal_Int16 >& rStartNumbering )
{
    sal_uInt32 nHardCount = 0;
    nHardCount += pParaObj->GetAttrib( PPT_ParaAttr_BulletOn, nIsBullet, nDestinationInstance ) ? 1 : 0;
@@ -6168,7 +6168,7 @@ bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& rRetValue, TSS_Ty
    return bIsHardAttribute;
}

void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  boost::optional< sal_Int16 >& rStartNumbering, SdrPowerPointImport const & rManager, TSS_Type nDestinationInstance )
void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  o3tl::optional< sal_Int16 >& rStartNumbering, SdrPowerPointImport const & rManager, TSS_Type nDestinationInstance )
{
    sal_Int16   nVal2;
    sal_uInt32  nVal, nUpperDist, nLowerDist;
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 4a6fbc0..1d49f17 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -1512,7 +1512,7 @@ IMPL_LINK_NOARG(ImpPDFTabSigningPage, ClickmaPbSignCertSelect, weld::Button&, vo

        try
        {
            boost::optional<css::uno::Sequence<OUString>> aTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get());
            o3tl::optional<css::uno::Sequence<OUString>> aTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get());
            if (aTSAURLs)
            {
                const css::uno::Sequence<OUString>& rTSAURLs = *aTSAURLs;
diff --git a/forms/inc/pch/precompiled_frm.hxx b/forms/inc/pch/precompiled_frm.hxx
index ed40761..d68969d 100644
--- a/forms/inc/pch/precompiled_frm.hxx
+++ b/forms/inc/pch/precompiled_frm.hxx
@@ -33,7 +33,7 @@
#include <utility>
#include <vector>
#include <boost/lexical_cast.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index 7c51f7c..e98c788 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -55,7 +55,7 @@
#include <unotools/sharedunocomponent.hxx>
#include <vcl/svapp.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <algorithm>
#include <iterator>
@@ -739,7 +739,7 @@ namespace frm
            return;
        }

        ::boost::optional< sal_Int16 > aBoundColumn(boost::none);
        ::o3tl::optional< sal_Int16 > aBoundColumn(o3tl::nullopt);
        if ( m_aBoundColumn.getValueType().getTypeClass() == TypeClass_SHORT )
        {
            sal_Int16 nBoundColumn( 0 );
diff --git a/framework/inc/pch/precompiled_fwe.hxx b/framework/inc/pch/precompiled_fwe.hxx
index c3abf13..11810cf 100644
--- a/framework/inc/pch/precompiled_fwe.hxx
+++ b/framework/inc/pch/precompiled_fwe.hxx
@@ -44,7 +44,7 @@
#include <type_traits>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/framework/inc/pch/precompiled_fwk.hxx b/framework/inc/pch/precompiled_fwk.hxx
index 2ae7536..9f48848 100644
--- a/framework/inc/pch/precompiled_fwk.hxx
+++ b/framework/inc/pch/precompiled_fwk.hxx
@@ -44,7 +44,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/conditn.h>
diff --git a/framework/inc/pch/precompiled_fwl.hxx b/framework/inc/pch/precompiled_fwl.hxx
index 59b5fff..103c91f 100644
--- a/framework/inc/pch/precompiled_fwl.hxx
+++ b/framework/inc/pch/precompiled_fwl.hxx
@@ -46,7 +46,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/framework/source/classes/taskcreator.cxx b/framework/source/classes/taskcreator.cxx
index 62762c8..f5c90bc 100644
--- a/framework/source/classes/taskcreator.cxx
+++ b/framework/source/classes/taskcreator.cxx
@@ -68,7 +68,7 @@ css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUStrin
           )
        {

            boost::optional<OUString> x(officecfg::Office::TabBrowse::TaskCreatorService::ImplementationName::get(m_xContext));
            o3tl::optional<OUString> x(officecfg::Office::TabBrowse::TaskCreatorService::ImplementationName::get(m_xContext));
            if (x) sCreator = *x;
        }

diff --git a/framework/source/services/substitutepathvars.cxx b/framework/source/services/substitutepathvars.cxx
index ad20f5e..371b5e8 100644
--- a/framework/source/services/substitutepathvars.cxx
+++ b/framework/source/services/substitutepathvars.cxx
@@ -256,7 +256,7 @@ OUString SubstitutePathVariables::GetWorkPath() const
OUString SubstitutePathVariables::GetWorkVariableValue() const
{
    OUString aWorkPath;
    boost::optional<OUString> x(officecfg::Office::Paths::Variables::Work::get(m_xContext));
    o3tl::optional<OUString> x(officecfg::Office::Paths::Variables::Work::get(m_xContext));
    if (!x)
    {
        // fallback to $HOME in case platform dependent config layer does not return
diff --git a/idlc/inc/astexpression.hxx b/idlc/inc/astexpression.hxx
index 5277462..ae96dff 100644
--- a/idlc/inc/astexpression.hxx
+++ b/idlc/inc/astexpression.hxx
@@ -24,7 +24,7 @@
#include <memory>

#include "idlc.hxx"
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

// Enum to define all the different operators to combine expressions
enum class ExprComb
@@ -130,7 +130,7 @@ private:
                    m_subExpr2;
    std::unique_ptr<AstExprValue>
                    m_exprValue;
    boost::optional<OString>
    o3tl::optional<OString>
                    m_xSymbolicName;
};

diff --git a/idlc/inc/astsequence.hxx b/idlc/inc/astsequence.hxx
index 2d65edb..0a8efc7 100644
--- a/idlc/inc/astsequence.hxx
+++ b/idlc/inc/astsequence.hxx
@@ -38,7 +38,7 @@ public:
    virtual const sal_Char* getRelativName() const override;
private:
    AstType const * m_pMemberType;
    mutable boost::optional<OString> m_xRelativName;
    mutable o3tl::optional<OString> m_xRelativName;
};

#endif // INCLUDED_IDLC_INC_ASTSEQUENCE_HXX
diff --git a/include/comphelper/configuration.hxx b/include/comphelper/configuration.hxx
index cb2ad56..7c2a0a7 100644
--- a/include/comphelper/configuration.hxx
+++ b/include/comphelper/configuration.hxx
@@ -12,7 +12,7 @@

#include <sal/config.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.h>
#include <comphelper/comphelperdllapi.h>
@@ -158,18 +158,18 @@ private:
};

/// @internal
template< typename T > struct Convert< boost::optional< T > >
template< typename T > struct Convert< o3tl::optional< T > >
{
    static css::uno::Any toAny(boost::optional< T > const & value) {
    static css::uno::Any toAny(o3tl::optional< T > const & value) {
        return value
            ? css::uno::makeAny(*value)
            : css::uno::Any();
    }

    static boost::optional< T > fromAny(css::uno::Any const & value)
    static o3tl::optional< T > fromAny(css::uno::Any const & value)
    {
        return value.hasValue()
            ? boost::optional< T >(value.get< T >()) : boost::optional< T >();
            ? o3tl::optional< T >(value.get< T >()) : o3tl::optional< T >();
    }

private:
@@ -200,7 +200,7 @@ template< typename T, typename U > struct ConfigurationProperty

    /// Get the value of the given (non-localized) configuration property.
    ///
    /// For nillable properties, U is of type boost::optional<U'>.
    /// For nillable properties, U is of type o3tl::optional<U'>.
    static U get(
        css::uno::Reference< css::uno::XComponentContext >
            const & context = comphelper::getProcessComponentContext())
@@ -216,7 +216,7 @@ template< typename T, typename U > struct ConfigurationProperty
    /// Set the value of the given (non-localized) configuration property, via a
    /// given changes batch.
    ///
    /// For nillable properties, U is of type boost::optional<U'>.
    /// For nillable properties, U is of type o3tl::optional<U'>.
    static void set(
        U const & value,
        std::shared_ptr< ConfigurationChanges > const & batch)
@@ -244,7 +244,7 @@ template< typename T, typename U > struct ConfigurationLocalizedProperty
    /// locale currently set at the
    /// com.sun.star.configuration.theDefaultProvider.
    ///
    /// For nillable properties, U is of type boost::optional<U'>.
    /// For nillable properties, U is of type o3tl::optional<U'>.
    static U get(css::uno::Reference< css::uno::XComponentContext > const & context)
    {
        // Folding this into one statement causes a bogus error at least with
@@ -260,7 +260,7 @@ template< typename T, typename U > struct ConfigurationLocalizedProperty
    /// com.sun.star.configuration.theDefaultProvider, via a given changes
    /// batch.
    ///
    /// For nillable properties, U is of type boost::optional<U'>.
    /// For nillable properties, U is of type o3tl::optional<U'>.
    static void set(
        U const & value,
        std::shared_ptr< ConfigurationChanges > const & batch)
diff --git a/include/comphelper/logging.hxx b/include/comphelper/logging.hxx
index 5057ff9..1fa7601 100644
--- a/include/comphelper/logging.hxx
+++ b/include/comphelper/logging.hxx
@@ -23,7 +23,7 @@
#include <comphelper/comphelperdllapi.h>
#include <rtl/ustring.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <memory>

namespace com::sun::star::uno { template <class interface_type> class Reference; }
@@ -65,7 +65,7 @@ namespace comphelper
    //= EventLogger

    class EventLogger_Impl;
    typedef ::boost::optional< OUString >    OptionalString;
    typedef ::o3tl::optional< OUString >    OptionalString;

    /** encapsulates a css::logging::XLogger

diff --git a/include/comphelper/unwrapargs.hxx b/include/comphelper/unwrapargs.hxx
index 7c1d26d..3ba4e213 100644
--- a/include/comphelper/unwrapargs.hxx
+++ b/include/comphelper/unwrapargs.hxx
@@ -22,7 +22,7 @@

#include <sal/config.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <rtl/ustrbuf.hxx>
#include <com/sun/star/uno/Sequence.hxx>
@@ -67,7 +67,7 @@ namespace detail {
    template< typename T, typename... Args >
    inline void unwrapArgs(
        const css::uno::Sequence< css::uno::Any >& seq,
        sal_Int32 nArg, ::boost::optional< T >& v, Args&... args );
        sal_Int32 nArg, ::o3tl::optional< T >& v, Args&... args );

    template< typename T, typename... Args >
    inline void unwrapArgs(
@@ -95,7 +95,7 @@ namespace detail {
    template< typename T, typename... Args >
    inline void unwrapArgs(
        const css::uno::Sequence< css::uno::Any >& seq,
        sal_Int32 nArg, ::boost::optional< T >& v, Args&... args )
        sal_Int32 nArg, ::o3tl::optional< T >& v, Args&... args )
    {
        if( nArg < seq.getLength() )
        {
diff --git a/include/connectivity/sqlerror.hxx b/include/connectivity/sqlerror.hxx
index 9b4c60c..9b75657 100644
--- a/include/connectivity/sqlerror.hxx
+++ b/include/connectivity/sqlerror.hxx
@@ -22,7 +22,7 @@

#include <com/sun/star/sdbc/SQLException.hpp>
#include <connectivity/dbtoolsdllapi.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <memory>

namespace connectivity
@@ -61,11 +61,11 @@ namespace connectivity

        // - optional

        /** convenience wrapper around boost::optional, allowing implicit construction
        /** convenience wrapper around o3tl::optional, allowing implicit construction
        */
        class ParamValue : public ::boost::optional< OUString >
        class ParamValue : public ::o3tl::optional< OUString >
        {
            typedef ::boost::optional< OUString >  base_type;
            typedef ::o3tl::optional< OUString >  base_type;

        public:
            ParamValue( ) : base_type( ) { }
diff --git a/include/cppcanvas/renderer.hxx b/include/cppcanvas/renderer.hxx
index 113bda7..ed1dc04 100644
--- a/include/cppcanvas/renderer.hxx
+++ b/include/cppcanvas/renderer.hxx
@@ -22,7 +22,7 @@

#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <cppcanvas/canvasgraphic.hxx>
#include <cppcanvas/color.hxx>
@@ -100,16 +100,16 @@ namespace cppcanvas
        struct Parameters
        {
            /// Optionally forces the fill color attribute for all actions
            ::boost::optional< IntSRGBA >                  maFillColor;
            ::o3tl::optional< IntSRGBA >                  maFillColor;

            /// Optionally forces the line color attribute for all actions
            ::boost::optional< IntSRGBA >                 maLineColor;
            ::o3tl::optional< IntSRGBA >                 maLineColor;

            /// Optionally forces the text color attribute for all actions
            ::boost::optional< IntSRGBA >                  maTextColor;
            ::o3tl::optional< IntSRGBA >                  maTextColor;

            /// Optionally forces the given fontname for all text actions
            ::boost::optional< OUString >                  maFontName;
            ::o3tl::optional< OUString >                  maFontName;

            /** Optionally transforms all text output actions with the
                given matrix (in addition to the overall canvas
@@ -119,16 +119,16 @@ namespace cppcanvas
                rect coordinate system, i.e. the metafile is assumed
                to be contained in the unit rect.
             */
            ::boost::optional< ::basegfx::B2DHomMatrix >    maTextTransformation;
            ::o3tl::optional< ::basegfx::B2DHomMatrix >    maTextTransformation;

            /// Optionally forces the given font weight for all text actions
            ::boost::optional< sal_Int8 >                   maFontWeight;
            ::o3tl::optional< sal_Int8 >                   maFontWeight;

            /// Optionally forces the given font letter form (italics etc.) for all text actions
            ::boost::optional< sal_Int8 >                   maFontLetterForm;
            ::o3tl::optional< sal_Int8 >                   maFontLetterForm;

            /// Optionally forces underlining for all text actions
            ::boost::optional< bool >                       maFontUnderline;
            ::o3tl::optional< bool >                       maFontUnderline;
        };
    };

diff --git a/include/dbaccess/genericcontroller.hxx b/include/dbaccess/genericcontroller.hxx
index 0d4d460..a63144e 100644
--- a/include/dbaccess/genericcontroller.hxx
+++ b/include/dbaccess/genericcontroller.hxx
@@ -27,7 +27,7 @@
#include <memory>
#include <vector>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <com/sun/star/awt/XUserInputInterception.hpp>
#include <com/sun/star/frame/CommandGroup.hpp>
@@ -94,7 +94,7 @@ namespace dbaui
    class ODataView;

    template< typename T >
    inline bool SAL_CALL operator >>= (const css::uno::Any& _any, boost::optional< T >& _value)
    inline bool SAL_CALL operator >>= (const css::uno::Any& _any, o3tl::optional< T >& _value)
    {
        _value.reset();  // de-init the optional value

@@ -118,10 +118,10 @@ namespace dbaui
    {
        bool                        bEnabled;

        boost::optional<bool> bChecked;
        boost::optional<bool> bInvisible;
        o3tl::optional<bool> bChecked;
        o3tl::optional<bool> bInvisible;
        css::uno::Any               aValue;
        boost::optional<OUString> sTitle;
        o3tl::optional<OUString> sTitle;

        FeatureState() : bEnabled(false) { }
    };
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index 12b4b0b..01dcffe 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -23,7 +23,7 @@
#include <memory>
#include <vector>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/i18n/WordType.hpp>
@@ -506,7 +506,7 @@ public:
    virtual OUString  GetUndoComment( sal_uInt16 nUndoId ) const;
    virtual bool    SpellNextDocument();
    virtual void    FieldClicked( const SvxFieldItem& rField );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor );

    // override this if access to bullet information needs to be provided
    virtual const SvxNumberFormat * GetNumberFormat( sal_Int32 nPara ) const;
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 70c08e5..2f6cc2d 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -40,7 +40,7 @@
#include <editeng/paragraphdata.hxx>
#include <o3tl/typed_flags_set.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <functional>
#include <memory>
#include <vector>
@@ -484,8 +484,8 @@ private:
    Outliner*           pOutliner;
    const SvxFieldItem& rFldItem;

    boost::optional<Color> mxTxtColor;
    boost::optional<Color> mxFldColor;
    o3tl::optional<Color> mxTxtColor;
    o3tl::optional<Color> mxFldColor;

    OUString            aRepresentation;

@@ -509,11 +509,11 @@ public:

    const SvxFieldItem& GetField() const { return rFldItem; }

    boost::optional<Color> const & GetTextColor() const { return mxTxtColor; }
    void            SetTextColor( boost::optional<Color> xCol ) { mxTxtColor = xCol; }
    o3tl::optional<Color> const & GetTextColor() const { return mxTxtColor; }
    void            SetTextColor( o3tl::optional<Color> xCol ) { mxTxtColor = xCol; }

    boost::optional<Color> const & GetFieldColor() const { return mxFldColor; }
    void            SetFieldColor( boost::optional<Color> xCol ) { mxFldColor = xCol; }
    o3tl::optional<Color> const & GetFieldColor() const { return mxFldColor; }
    void            SetFieldColor( o3tl::optional<Color> xCol ) { mxFldColor = xCol; }

    sal_Int32       GetPara() const { return nPara; }
    sal_Int32       GetPos() const { return nPos; }
@@ -880,7 +880,7 @@ public:
    bool            UpdateFields();
    void            RemoveFields( const std::function<bool ( const SvxFieldData* )>& isFieldData = [] (const SvxFieldData* ){return true;} );

    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor );

    void            SetSpeller( css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpeller );
    css::uno::Reference< css::linguistic2::XSpellChecker1 > const &
diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx
index 46c3df2..cde80d6 100644
--- a/include/editeng/svxacorr.hxx
+++ b/include/editeng/svxacorr.hxx
@@ -28,7 +28,7 @@
#include <editeng/swafopt.hxx>
#include <editeng/editengdllapi.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <map>
#include <memory>

@@ -155,7 +155,7 @@ public:
                           ~SvxAutocorrWordList();
    void                   DeleteAndDestroyAll();
    const SvxAutocorrWord* Insert(SvxAutocorrWord aWord) const;
    boost::optional<SvxAutocorrWord> FindAndRemove(const SvxAutocorrWord *pWord);
    o3tl::optional<SvxAutocorrWord> FindAndRemove(const SvxAutocorrWord *pWord);
    void                   LoadEntry(const OUString& sWrong, const OUString& sRight, bool bOnlyTxt);
    bool                   empty() const;

diff --git a/include/editeng/unoedprx.hxx b/include/editeng/unoedprx.hxx
index 132cbbf..a3aa0b9 100644
--- a/include/editeng/unoedprx.hxx
+++ b/include/editeng/unoedprx.hxx
@@ -54,7 +54,7 @@ public:

    virtual SfxItemPool*    GetPool() const override;

    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) override;
    virtual void            FieldClicked( const SvxFieldItem& rField ) override;

    virtual bool            IsValid() const override;
diff --git a/include/editeng/unoedsrc.hxx b/include/editeng/unoedsrc.hxx
index e9f3ee0..ab8a567 100644
--- a/include/editeng/unoedsrc.hxx
+++ b/include/editeng/unoedsrc.hxx
@@ -159,7 +159,7 @@ public:
    virtual void        QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) = 0;
    virtual void        QuickInsertLineBreak( const ESelection& rSel ) = 0;

    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) = 0;
    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) = 0;
    virtual void        FieldClicked( const SvxFieldItem& rField ) = 0;

    virtual SfxItemPool* GetPool() const = 0;
diff --git a/include/editeng/unofored.hxx b/include/editeng/unofored.hxx
index 8222a30..a0cf70c 100644
--- a/include/editeng/unofored.hxx
+++ b/include/editeng/unofored.hxx
@@ -54,7 +54,7 @@ public:

    virtual SfxItemPool* GetPool() const override;

    virtual OUString     CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
    virtual OUString     CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) override;
    virtual void         FieldClicked( const SvxFieldItem& rField ) override;
    virtual bool         IsValid() const override;

diff --git a/include/editeng/unoforou.hxx b/include/editeng/unoforou.hxx
index f2d28a5..17029f9 100644
--- a/include/editeng/unoforou.hxx
+++ b/include/editeng/unoforou.hxx
@@ -72,7 +72,7 @@ public:

    virtual SfxItemPool* GetPool() const override;

    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
    virtual OUString    CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) override;
    virtual void        FieldClicked( const SvxFieldItem& rField ) override;

    virtual bool        IsValid() const override;
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index 203bf30..4fae9a9 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -189,7 +189,7 @@ public:
    virtual void            QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) override;
    virtual void            QuickInsertLineBreak( const ESelection& rSel ) override;

    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) override;
    virtual void            FieldClicked( const SvxFieldItem& rField ) override;

    virtual bool            IsValid() const override;
diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx
index 341dc2b..efb71e6 100644
--- a/include/filter/msfilter/msdffimp.hxx
+++ b/include/filter/msfilter/msdffimp.hxx
@@ -28,7 +28,7 @@
#include <vector>
#include <unordered_map>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <comphelper/stl_types.hxx>
@@ -226,9 +226,9 @@ struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
                    pClientDataBuffer;
    sal_uInt32      nClientDataLen;
    sal_uInt32      nXAlign;
    boost::optional<sal_uInt32> nXRelTo;
    o3tl::optional<sal_uInt32> nXRelTo;
    sal_uInt32      nYAlign;
    boost::optional<sal_uInt32> nYRelTo;
    o3tl::optional<sal_uInt32> nYRelTo;
    sal_uInt32      nLayoutInTableCell;
    ShapeFlag       nFlags;
    sal_Int32       nDxTextLeft;    ///< distance of text box from surrounding shape
diff --git a/include/filter/msfilter/svdfppt.hxx b/include/filter/msfilter/svdfppt.hxx
index 51bdd19..ec50015 100644
--- a/include/filter/msfilter/svdfppt.hxx
+++ b/include/filter/msfilter/svdfppt.hxx
@@ -25,7 +25,7 @@
#include <memory>
#include <vector>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <com/sun/star/uno/Reference.hxx>
#include <editeng/eeitem.hxx>
@@ -491,7 +491,7 @@ struct MSFILTER_DLLPUBLIC PPTFieldEntry
    sal_uInt16          nTextRangeEnd;
    std::unique_ptr<SvxFieldItem> xField1;
    std::unique_ptr<SvxFieldItem> xField2;
    boost::optional<OUString> xString;
    o3tl::optional<OUString> xString;

    PPTFieldEntry()
        : nPos(0)
@@ -813,7 +813,7 @@ class PPTNumberFormatCreator
                    sal_uInt32 nLevel,
                    TSS_Type nInstance,
                    TSS_Type nInstanceInSheet,
                    boost::optional< sal_Int16 >& rStartNumbering,
                    o3tl::optional< sal_Int16 >& rStartNumbering,
                    sal_uInt32 nFontHeight,
                    PPTParagraphObj const * pPara
                );
@@ -841,7 +841,7 @@ public:
                    SvxNumberFormat& rNumberFormat,
                    PPTParagraphObj* pPara,
                    TSS_Type nInstanceInSheet,
                    boost::optional< sal_Int16 >& rStartNumbering
                    o3tl::optional< sal_Int16 >& rStartNumbering
                );
};

@@ -1177,7 +1177,7 @@ public:
    void                    AppendPortion( PPTPortionObj& rPortion );
    void                    ApplyTo(
                                SfxItemSet& rSet,
                                boost::optional< sal_Int16 >& rStartNumbering,
                                o3tl::optional< sal_Int16 >& rStartNumbering,
                                SdrPowerPointImport const & rManager,
                                TSS_Type nInstanceInSheet
                            );
diff --git a/include/o3tl/any.hxx b/include/o3tl/any.hxx
index 141d788..b4d9e52 100644
--- a/include/o3tl/any.hxx
+++ b/include/o3tl/any.hxx
@@ -16,7 +16,7 @@
#include <type_traits>
#include <utility>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/RuntimeException.hpp>
@@ -36,37 +36,37 @@ namespace detail {
struct Void {};

template<typename T> struct Optional { using type = T const *; };
template<> struct Optional<void> { using type = boost::optional<Void const>; };
template<> struct Optional<bool> { using type = boost::optional<bool const>; };
template<> struct Optional<void> { using type = o3tl::optional<Void const>; };
template<> struct Optional<bool> { using type = o3tl::optional<bool const>; };
template<> struct Optional<sal_Int8> {
    using type = boost::optional<sal_Int8 const>;
    using type = o3tl::optional<sal_Int8 const>;
};
template<> struct Optional<sal_Int16> {
    using type = boost::optional<sal_Int16 const>;
    using type = o3tl::optional<sal_Int16 const>;
};
template<> struct Optional<sal_uInt16> {
    using type = boost::optional<sal_uInt16 const>;
    using type = o3tl::optional<sal_uInt16 const>;
};
template<> struct Optional<sal_Int32> {
    using type = boost::optional<sal_Int32 const>;
    using type = o3tl::optional<sal_Int32 const>;
};
template<> struct Optional<sal_uInt32> {
    using type = boost::optional<sal_uInt32 const>;
    using type = o3tl::optional<sal_uInt32 const>;
};
template<> struct Optional<sal_Int64> {
    using type = boost::optional<sal_Int64 const>;
    using type = o3tl::optional<sal_Int64 const>;
};
template<> struct Optional<sal_uInt64> {
    using type = boost::optional<sal_uInt64 const>;
    using type = o3tl::optional<sal_uInt64 const>;
};
template<> struct Optional<float> {
    using type = boost::optional<float const>;
    using type = o3tl::optional<float const>;
};
template<> struct Optional<double> {
    using type = boost::optional<double const>;
    using type = o3tl::optional<double const>;
};
template<typename T> struct Optional<css::uno::Reference<T>> {
    using type = boost::optional<css::uno::Reference<T> const>;
    using type = o3tl::optional<css::uno::Reference<T> const>;
};
template<> struct Optional<css::uno::Reference<css::uno::XInterface>> {
    using type = css::uno::Reference<css::uno::XInterface> const *;
@@ -85,12 +85,12 @@ template<typename T> struct IsUnoSequenceType<cppu::UnoSequenceType<T>>:
    std::true_type
{};

template<typename T> inline boost::optional<T const> tryGetConverted(
template<typename T> inline o3tl::optional<T const> tryGetConverted(
    css::uno::Any const & any)
{
    T v;
    return (any >>= v)
        ? boost::optional<T const>(std::move(v)) : boost::optional<T const>();
        ? o3tl::optional<T const>(std::move(v)) : o3tl::optional<T const>();
}

}
@@ -105,7 +105,7 @@ template<typename T> inline boost::optional<T const> tryGetConverted(
    proxy is positive.  For a positive proxy P representing a value of requested
    type T, for any T other than void, the expression *P yields that value of
    type T.  (Technically, the proxy is either a plain pointer or a
    boost::optional, depending on whether a plain pointer into the given Any can
    o3tl::optional, depending on whether a plain pointer into the given Any can
    be returned for the specified type.)

    @attention A proxy returned from this function must not outlive the
@@ -124,7 +124,7 @@ template<typename T> inline boost::optional<T const> tryGetConverted(
    @note Ideally this would be a public member function of css::uno::Any (at
    least conditional on LIBO_INTERNAL_ONLY, as it requires C++11).  However, as
    std::optional (which would be needed to implement the proxies) is only
    available since C++14, we need to use boost::optional for now.  But To not
    available since C++14, we need to use o3tl::optional for now.  But To not
    make every entity that includes <com/sun/star/uno/Any.hxx> depend on
    boost_headers, keep this here for now.

@@ -156,8 +156,8 @@ template<> inline detail::Optional<void>::type tryAccess<void>(
    css::uno::Any const & any)
{
    return any.hasValue()
        ? boost::optional<detail::Void const>()
        : boost::optional<detail::Void const>(detail::Void());
        ? o3tl::optional<detail::Void const>()
        : o3tl::optional<detail::Void const>(detail::Void());
}

template<> inline detail::Optional<bool>::type tryAccess<bool>(
diff --git a/include/o3tl/optional.hxx b/include/o3tl/optional.hxx
new file mode 100644
index 0000000..6da8569
--- /dev/null
+++ b/include/o3tl/optional.hxx
@@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

// A wrapper selecting either std::optional or boost::optional as a fallback for Xcode < 10.  To be
// removed once std::optional is available everywhere.

#ifndef INCLUDED_O3TL_OPTIONAL_HXX
#define INCLUDED_O3TL_OPTIONAL_HXX

#include <sal/config.h>

#if defined __APPLE__ && !__has_include(<optional>)

#include <boost/none.hpp>
#include <boost/optional.hpp>

namespace o3tl
{
using boost::make_optional;
using boost::optional;

inline constexpr auto nullopt = boost::none;
}

#else

#include <optional>

namespace o3tl
{
using std::make_optional;
using std::nullopt;
using std::optional;
}

#endif

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/oox/helper/helper.hxx b/include/oox/helper/helper.hxx
index d2077aa..5a83c37 100644
--- a/include/oox/helper/helper.hxx
+++ b/include/oox/helper/helper.hxx
@@ -154,7 +154,7 @@ inline void setFlag( Type& ornBitField, Type nMask, bool bSet = true )
}


/** Optional value, similar to ::boost::optional<>, with convenience accessors.
/** Optional value, similar to ::o3tl::optional<>, with convenience accessors.
 */
template< typename Type >
class OptValue
diff --git a/include/sax/tools/converter.hxx b/include/sax/tools/converter.hxx
index 967c395..42b7697 100644
--- a/include/sax/tools/converter.hxx
+++ b/include/sax/tools/converter.hxx
@@ -22,7 +22,7 @@

#include <sal/config.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <sax/saxdllapi.h>

@@ -196,7 +196,7 @@ public:
                    css::util::Date * pDate,
                    css::util::DateTime & rDateTime,
                    bool & rbDateTime,
                    boost::optional<sal_Int16> * pTimeZoneOffset,
                    o3tl::optional<sal_Int16> * pTimeZoneOffset,
                    const OUString & rString );

    /** gets the position of the first comma after npos in the string
diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
index 08be8bb..b02a313 100644
--- a/include/sfx2/dinfdlg.hxx
+++ b/include/sfx2/dinfdlg.hxx
@@ -36,7 +36,7 @@

#include <sfx2/tabdlg.hxx>

#include <boost/optional/optional.hpp>
#include <o3tl/optional.hxx>
#include <memory>

namespace com::sun::star::beans { struct PropertyValue; }
@@ -249,7 +249,7 @@ class CustomPropertiesDateField
private:
    std::unique_ptr<SvtCalendarBox> m_xDateField;
public:
    ::boost::optional<sal_Int16> m_TZ;
    ::o3tl::optional<sal_Int16> m_TZ;

    CustomPropertiesDateField(SvtCalendarBox* pDateField);
    void set_visible(bool bVisible) { m_xDateField->set_visible(bVisible); }
diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index 596382a..e65bceb 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -36,7 +36,7 @@
#include <com/sun/star/ui/XContextChangeEventListener.hpp>
#include <com/sun/star/ui/XSidebar.hpp>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>

@@ -196,8 +196,8 @@ private:
        mbIsDeckRequestedOpen.  Normally both flags have the same
        value.  A document being read-only can prevent the deck from opening.
    */
    ::boost::optional<bool> mbIsDeckRequestedOpen;
    ::boost::optional<bool> mbIsDeckOpen;
    ::o3tl::optional<bool> mbIsDeckRequestedOpen;
    ::o3tl::optional<bool> mbIsDeckOpen;

    bool mbFloatingDeckClosed;

diff --git a/include/svtools/table/tablemodel.hxx b/include/svtools/table/tablemodel.hxx
index 088b9a8..8fadf6f 100644
--- a/include/svtools/table/tablemodel.hxx
+++ b/include/svtools/table/tablemodel.hxx
@@ -30,7 +30,7 @@

#include <sal/types.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <memory>
#include <vector>
#include <o3tl/typed_flags_set.hxx>
@@ -365,55 +365,55 @@ namespace svt { namespace table

            If this value is not set, a default color from the style settings will be used.
        */
        virtual ::boost::optional< ::Color >    getLineColor() const = 0;
        virtual ::o3tl::optional< ::Color >    getLineColor() const = 0;

        /** returns the color to be used for rendering the header background.

            If this value is not set, a default color from the style settings will be used.
        */
        virtual ::boost::optional< ::Color >    getHeaderBackgroundColor() const = 0;
        virtual ::o3tl::optional< ::Color >    getHeaderBackgroundColor() const = 0;

        /** returns the color to be used for rendering the header text.

            If this value is not set, a default color from the style settings will be used.
        */
        virtual ::boost::optional< ::Color >    getHeaderTextColor() const = 0;
        virtual ::o3tl::optional< ::Color >    getHeaderTextColor() const = 0;

        /** returns the color to be used for the background of selected cells, when the control has the focus

            If this value is not set, a default color from the style settings will be used.
        */
        virtual ::boost::optional< ::Color >    getActiveSelectionBackColor() const = 0;
        virtual ::o3tl::optional< ::Color >    getActiveSelectionBackColor() const = 0;

        /** returns the color to be used for the background of selected cells, when the control does not have the focus

            If this value is not set, a default color from the style settings will be used.
        */
        virtual ::boost::optional< ::Color >    getInactiveSelectionBackColor() const = 0;
        virtual ::o3tl::optional< ::Color >    getInactiveSelectionBackColor() const = 0;

        /** returns the color to be used for the text of selected cells, when the control has the focus

            If this value is not set, a default color from the style settings will be used.
        */
        virtual ::boost::optional< ::Color >    getActiveSelectionTextColor() const = 0;
        virtual ::o3tl::optional< ::Color >    getActiveSelectionTextColor() const = 0;

        /** returns the color to be used for the text of selected cells, when the control does not have the focus

            If this value is not set, a default color from the style settings will be used.
        */
        virtual ::boost::optional< ::Color >    getInactiveSelectionTextColor() const = 0;
        virtual ::o3tl::optional< ::Color >    getInactiveSelectionTextColor() const = 0;

        /** returns the color to be used for rendering cell texts.

            If this value is not set, a default color from the style settings will be used.
        */
        virtual ::boost::optional< ::Color >    getTextColor() const = 0;
        virtual ::o3tl::optional< ::Color >    getTextColor() const = 0;

        /** returns the color to be used for text lines (underline, strikethrough) when rendering cell text.

            If this value is not set, a default color from the style settings will be used.
        */
        virtual ::boost::optional< ::Color >    getTextLineColor() const = 0;
        virtual ::o3tl::optional< ::Color >    getTextLineColor() const = 0;

        /** returns the colors to be used for the row backgrounds.

@@ -426,7 +426,7 @@ namespace svt { namespace table
            If value is a non-empty sequence, then rows will have the background colors as specified in the sequence,
            in alternating order.
        */
        virtual ::boost::optional< ::std::vector< ::Color > >
        virtual ::o3tl::optional< ::std::vector< ::Color > >
                                                getRowBackgroundColors() const = 0;

        /** determines the vertical alignment of content within a cell
diff --git a/include/svx/ClassificationEditView.hxx b/include/svx/ClassificationEditView.hxx
index fbea139..8c30518 100644
--- a/include/svx/ClassificationEditView.hxx
+++ b/include/svx/ClassificationEditView.hxx
@@ -24,7 +24,7 @@ class ClassificationEditEngine final : public EditEngine
public:
    ClassificationEditEngine(SfxItemPool* pItemPool);

    virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor) override;
    virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor) override;
};

class ClassificationEditView final : public WeldEditView
diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx
index cce1df5..bb182c6 100644
--- a/include/svx/svdomeas.hxx
+++ b/include/svx/svdomeas.hxx
@@ -140,7 +140,7 @@ public:
    virtual OutlinerParaObject* GetOutlinerParaObject() const override;

    virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
        bool bEdit, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor, OUString& rRet) const override;
        bool bEdit, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor, OUString& rRet) const override;

    // #i97878#
    virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const override;
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index d49f122..ccb6686 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -497,7 +497,7 @@ public:
    virtual void NbcReformatText() override;

    virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
        bool bEdit, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor, OUString& rRet) const;
        bool bEdit, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor, OUString& rRet) const;

    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;

diff --git a/include/svx/svdoutl.hxx b/include/svx/svdoutl.hxx
index 7655dee..eb1b515 100644
--- a/include/svx/svdoutl.hxx
+++ b/include/svx/svdoutl.hxx
@@ -43,7 +43,7 @@ public:
    void setVisualizedPage(const SdrPage* pPage) { if(pPage != mpVisualizedPage) mpVisualizedPage = pPage; }
    const SdrPage* getVisualizedPage() const { return mpVisualizedPage; }

    virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor) override;
    virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor) override;

    bool hasEditViewCallbacks() const;
};
diff --git a/include/toolkit/controls/unocontrols.hxx b/include/toolkit/controls/unocontrols.hxx
index 5ea17a4..6bc0faf 100644
--- a/include/toolkit/controls/unocontrols.hxx
+++ b/include/toolkit/controls/unocontrols.hxx
@@ -54,7 +54,7 @@
#include <memory>
#include <vector>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace com { namespace sun { namespace star { namespace graphic { class XGraphic; } } } }
namespace com { namespace sun { namespace star { namespace graphic { class XGraphicObject; } } } }
@@ -804,15 +804,15 @@ protected:
private:
    void    impl_notifyItemListEvent_nolck(
                const sal_Int32 i_nItemPosition,
                const ::boost::optional< OUString >& i_rItemText,
                const ::boost::optional< OUString >& i_rItemImageURL,
                const ::o3tl::optional< OUString >& i_rItemText,
                const ::o3tl::optional< OUString >& i_rItemImageURL,
                void ( SAL_CALL css::awt::XItemListListener::*NotificationMethod )( const css::awt::ItemListEvent& )
            );

    void    impl_handleInsert(
                const sal_Int32 i_nItemPosition,
                const ::boost::optional< OUString >& i_rItemText,
                const ::boost::optional< OUString >& i_rItemImageURL,
                const ::o3tl::optional< OUString >& i_rItemText,
                const ::o3tl::optional< OUString >& i_rItemImageURL,
                ::osl::ClearableMutexGuard& i_rClearBeforeNotify
            );

@@ -823,8 +823,8 @@ private:

    void    impl_handleModify(
                const sal_Int32 i_nItemPosition,
                const ::boost::optional< OUString >& i_rItemText,
                const ::boost::optional< OUString >& i_rItemImageURL,
                const ::o3tl::optional< OUString >& i_rItemText,
                const ::o3tl::optional< OUString >& i_rItemImageURL,
                ::osl::ClearableMutexGuard& i_rClearBeforeNotify
            );

diff --git a/include/unotools/historyoptions.hxx b/include/unotools/historyoptions.hxx
index 87ce484..b723dc9 100644
--- a/include/unotools/historyoptions.hxx
+++ b/include/unotools/historyoptions.hxx
@@ -27,7 +27,7 @@
#include <unotools/options.hxx>
#include <memory>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace com { namespace sun { namespace star { namespace beans { struct PropertyValue; } } } }

@@ -86,7 +86,7 @@ public:
    */
    void AppendItem(EHistoryType eHistory,
            const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
            const boost::optional<OUString>& sThumbnail);
            const o3tl::optional<OUString>& sThumbnail);

    /** Delete item from the specified list.
    */
diff --git a/include/vcl/fontcapabilities.hxx b/include/vcl/fontcapabilities.hxx
index 51aa13e..539dd27 100644
--- a/include/vcl/fontcapabilities.hxx
+++ b/include/vcl/fontcapabilities.hxx
@@ -10,7 +10,7 @@
#ifndef INCLUDED_VCL_FONTCAPABILITIES_HXX
#define INCLUDED_VCL_FONTCAPABILITIES_HXX

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <bitset>

//See OS/2 table, i.e. http://www.microsoft.com/typography/otspec/os2.htm#ur
@@ -193,8 +193,8 @@ namespace vcl

    struct FontCapabilities
    {
        boost::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> oUnicodeRange;
        boost::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> oCodePageRange;
        o3tl::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> oUnicodeRange;
        o3tl::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> oCodePageRange;
    };
}

diff --git a/include/vcl/outdevstate.hxx b/include/vcl/outdevstate.hxx
index 4938552..5f0b12d 100644
--- a/include/vcl/outdevstate.hxx
+++ b/include/vcl/outdevstate.hxx
@@ -28,7 +28,7 @@
#include <tools/fontenum.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <memory>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <i18nlangtag/lang.h>

namespace vcl { class Font; }
@@ -81,17 +81,17 @@ struct OutDevState
    OutDevState(OutDevState&&);
    ~OutDevState();

    boost::optional<MapMode>        mpMapMode;
    o3tl::optional<MapMode>        mpMapMode;
    bool            mbMapActive;
    std::unique_ptr<vcl::Region>    mpClipRegion;
    boost::optional<Color>          mpLineColor;
    boost::optional<Color>          mpFillColor;
    o3tl::optional<Color>          mpLineColor;
    o3tl::optional<Color>          mpFillColor;
    std::unique_ptr<vcl::Font>      mpFont;
    boost::optional<Color>          mpTextColor;
    boost::optional<Color>          mpTextFillColor;
    boost::optional<Color>          mpTextLineColor;
    boost::optional<Color>          mpOverlineColor;
    boost::optional<Point>          mpRefPoint;
    o3tl::optional<Color>          mpTextColor;
    o3tl::optional<Color>          mpTextFillColor;
    o3tl::optional<Color>          mpTextLineColor;
    o3tl::optional<Color>          mpOverlineColor;
    o3tl::optional<Point>          mpRefPoint;
    TextAlign       meTextAlign;
    RasterOp        meRasterOp;
    ComplexTextLayoutFlags  mnTextLayoutMode;
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 1f879b1..a45e0e6 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -29,7 +29,7 @@
#include <memory>
#include <vector>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class BitmapEx;
class LanguageTag;
@@ -549,7 +549,7 @@ public:

    BitmapEx const &                GetPersonaFooter() const;

    const boost::optional<Color>&   GetPersonaMenuBarTextColor() const;
    const o3tl::optional<Color>&   GetPersonaMenuBarTextColor() const;

    // global switch to allow EdgeBlenging; currently possible for ValueSet and ListBox
    // when activated there using Get/SetEdgeBlending; default is true
diff --git a/include/vcl/threadex.hxx b/include/vcl/threadex.hxx
index 05d0bad..ceb3354 100644
--- a/include/vcl/threadex.hxx
+++ b/include/vcl/threadex.hxx
@@ -24,7 +24,7 @@
#include <tools/link.hxx>
#include <vcl/dllapi.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <memory>

namespace vcl
@@ -84,9 +84,9 @@ private:
#else
    FuncT const m_func;
#endif
    // using boost::optional here omits the need that ResultT is default
    // using o3tl::optional here omits the need that ResultT is default
    // constructable:
    ::boost::optional<ResultT> m_result;
    ::o3tl::optional<ResultT> m_result;
};

template <typename FuncT>
diff --git a/include/vcl/treelistentry.hxx b/include/vcl/treelistentry.hxx
index 71c8e82..deb733b 100644
--- a/include/vcl/treelistentry.hxx
+++ b/include/vcl/treelistentry.hxx
@@ -27,7 +27,7 @@
#include <vcl/treelistentries.hxx>
#include <o3tl/typed_flags_set.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <vector>
#include <memory>

@@ -64,7 +64,7 @@ class VCL_DLLPUBLIC SvTreeListEntry
    void*               pUserData;
    SvTLEntryFlags      nEntryFlags;
    Color               maBackColor;
    boost::optional<Color> mxTextColor;
    o3tl::optional<Color> mxTextColor;

private:
    void ClearChildren();
@@ -112,8 +112,8 @@ public:
    void SetBackColor( const Color& rColor ) { maBackColor = rColor; }
    const Color& GetBackColor() const { return maBackColor; }

    void SetTextColor( boost::optional<Color> xColor ) { mxTextColor = xColor; }
    boost::optional<Color> const & GetTextColor() const { return mxTextColor; }
    void SetTextColor( o3tl::optional<Color> xColor ) { mxTextColor = xColor; }
    o3tl::optional<Color> const & GetTextColor() const { return mxTextColor; }

    SvTreeListEntry* GetParent() const { return pParent; }

diff --git a/jvmfwk/inc/elements.hxx b/jvmfwk/inc/elements.hxx
index 4ec2e5c2..89802e9 100644
--- a/jvmfwk/inc/elements.hxx
+++ b/jvmfwk/inc/elements.hxx
@@ -27,7 +27,7 @@
#include <rtl/ustring.hxx>
#include <rtl/byteseq.hxx>
#include <libxml/parser.h>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

struct JavaInfo;

@@ -159,28 +159,28 @@ private:
        If /java/enabled@xsi:nil == true then the value will be uninitialized
        after a call to load().
    */
    boost::optional<sal_Bool> m_enabled;
    o3tl::optional<sal_Bool> m_enabled;

    /** User configurable option. /java/userClassPath
        If /java/userClassPath@xsi:nil == true then the value is uninitialized
        after a call to load().
    */
    boost::optional< OUString> m_userClassPath;
    o3tl::optional< OUString> m_userClassPath;
    /** User configurable option.  /java/javaInfo
        If /java/javaInfo@xsi:nil == true then the value is uninitialized
        after a call to load.
     */
    boost::optional<CNodeJavaInfo> m_javaInfo;
    o3tl::optional<CNodeJavaInfo> m_javaInfo;
    /** User configurable option. /java/vmParameters
        If /java/vmParameters@xsi:nil == true then the value is uninitialized
        after a call to load.
    */
    boost::optional< ::std::vector< OUString> > m_vmParameters;
    o3tl::optional< ::std::vector< OUString> > m_vmParameters;
    /** User configurable option. /java/jreLocations
        If /java/jreLocaltions@xsi:nil == true then the value is uninitialized
        after a call to load.
    */
    boost::optional< ::std::vector< OUString> > m_JRELocations;
    o3tl::optional< ::std::vector< OUString> > m_JRELocations;

public:

@@ -225,22 +225,22 @@ public:

    /** returns the value of the element /java/enabled
     */
    const boost::optional<sal_Bool> & getEnabled() const { return m_enabled;}
    const o3tl::optional<sal_Bool> & getEnabled() const { return m_enabled;}
    /** returns the value of the element /java/userClassPath.
     */
    const boost::optional< OUString> & getUserClassPath() const { return m_userClassPath;}
    const o3tl::optional< OUString> & getUserClassPath() const { return m_userClassPath;}

    /** returns the value of the element /java/javaInfo.
     */
    const boost::optional<CNodeJavaInfo> & getJavaInfo() const { return m_javaInfo;}
    const o3tl::optional<CNodeJavaInfo> & getJavaInfo() const { return m_javaInfo;}

    /** returns the parameters from the element /java/vmParameters/param.
     */
    const boost::optional< ::std::vector< OUString> > & getVmParameters() const { return m_vmParameters;}
    const o3tl::optional< ::std::vector< OUString> > & getVmParameters() const { return m_vmParameters;}

    /** returns the parameters from the element /java/jreLocations/location.
     */
    const boost::optional< ::std::vector< OUString> > & getJRELocations() const { return m_JRELocations;}
    const o3tl::optional< ::std::vector< OUString> > & getJRELocations() const { return m_JRELocations;}
};

/** merges the settings for shared, user and installation during construction.
diff --git a/jvmfwk/inc/fwkbase.hxx b/jvmfwk/inc/fwkbase.hxx
index 790b9a4..07ea10a 100644
--- a/jvmfwk/inc/fwkbase.hxx
+++ b/jvmfwk/inc/fwkbase.hxx
@@ -21,7 +21,7 @@

#include <sal/config.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <rtl/ustring.hxx>
#include "libxmlutil.hxx"
@@ -40,7 +40,7 @@ class VendorSettings
public:
    VendorSettings();

    boost::optional<VersionInfo> getVersionInformation(const OUString & sVendor) const;
    o3tl::optional<VersionInfo> getVersionInformation(const OUString & sVendor) const;
};

/* The class offers functions to retrieve verified bootstrap parameters.
diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx
index bc4a4b7..69688df 100644
--- a/jvmfwk/source/elements.cxx
+++ b/jvmfwk/source/elements.cxx
@@ -34,7 +34,7 @@
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <string.h>

// For backwards compatibility, the nFeatures and nRequirements flag words are
@@ -236,9 +236,9 @@ void NodeJava::load()
                CXmlCharPtr sEnabled( xmlNodeListGetString(
                    docUser, cur->children, 1));
                if (xmlStrcmp(sEnabled, reinterpret_cast<xmlChar const *>("true")) == 0)
                    m_enabled = boost::optional<sal_Bool>(true);
                    m_enabled = o3tl::optional<sal_Bool>(true);
                else if (xmlStrcmp(sEnabled, reinterpret_cast<xmlChar const *>("false")) == 0)
                    m_enabled = boost::optional<sal_Bool>(false);
                    m_enabled = o3tl::optional<sal_Bool>(false);
            }
        }
        else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("userClassPath")) == 0)
@@ -251,7 +251,7 @@ void NodeJava::load()
            {
                CXmlCharPtr sUser(xmlNodeListGetString(
                    docUser, cur->children, 1));
                m_userClassPath = boost::optional<OUString>(OUString(sUser));
                m_userClassPath = o3tl::optional<OUString>(OUString(sUser));
            }
        }
        else if (xmlStrcmp(cur->name, reinterpret_cast<xmlChar const *>("javaInfo")) == 0)
@@ -264,7 +264,7 @@ void NodeJava::load()
            if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("false")) == 0)
            {
                if (! m_javaInfo)
                    m_javaInfo = boost::optional<CNodeJavaInfo>(CNodeJavaInfo());
                    m_javaInfo = o3tl::optional<CNodeJavaInfo>(CNodeJavaInfo());
                m_javaInfo->loadFromNode(docUser, cur);
            }
        }
@@ -277,7 +277,7 @@ void NodeJava::load()
            if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("false")) == 0)
            {
                if ( ! m_vmParameters)
                    m_vmParameters = boost::optional<std::vector<OUString> >(
                    m_vmParameters = o3tl::optional<std::vector<OUString> >(
                        std::vector<OUString> ());

                xmlNode * pOpt = cur->children;
@@ -302,7 +302,7 @@ void NodeJava::load()
            if (xmlStrcmp(sNil, reinterpret_cast<xmlChar const *>("false")) == 0)
            {
                if (! m_JRELocations)
                    m_JRELocations = boost::optional<std::vector<OUString> >(
                    m_JRELocations = o3tl::optional<std::vector<OUString> >(
                        std::vector<OUString>());

                xmlNode * pLoc = cur->children;
@@ -418,7 +418,7 @@ void NodeJava::write() const
                     reinterpret_cast<xmlChar const *>("nil"),
                     reinterpret_cast<xmlChar const *>("false"));

        if (m_enabled == boost::optional<sal_Bool>(true))
        if (m_enabled == o3tl::optional<sal_Bool>(true))
            xmlNodeSetContent(nodeEnabled,reinterpret_cast<xmlChar const *>("true"));
        else
            xmlNodeSetContent(nodeEnabled,reinterpret_cast<xmlChar const *>("false"));
@@ -531,19 +531,19 @@ void NodeJava::write() const

void NodeJava::setEnabled(bool bEnabled)
{
    m_enabled =  boost::optional<sal_Bool>(bEnabled);
    m_enabled =  o3tl::optional<sal_Bool>(bEnabled);
}


void NodeJava::setUserClassPath(const OUString & sClassPath)
{
    m_userClassPath = boost::optional<OUString>(sClassPath);
    m_userClassPath = o3tl::optional<OUString>(sClassPath);
}

void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect)
{
    if (!m_javaInfo)
        m_javaInfo = boost::optional<CNodeJavaInfo>(CNodeJavaInfo());
        m_javaInfo = o3tl::optional<CNodeJavaInfo>(CNodeJavaInfo());
    m_javaInfo->bAutoSelect = bAutoSelect;
    m_javaInfo->bNil = false;

@@ -571,13 +571,13 @@ void NodeJava::setJavaInfo(const JavaInfo * pInfo, bool bAutoSelect)

void NodeJava::setVmParameters(std::vector<OUString> const & arOptions)
{
    m_vmParameters = boost::optional<std::vector<OUString> >(arOptions);
    m_vmParameters = o3tl::optional<std::vector<OUString> >(arOptions);
}

void NodeJava::addJRELocation(OUString const & sLocation)
{
    if (!m_JRELocations)
        m_JRELocations = boost::optional<std::vector<OUString> >(
        m_JRELocations = o3tl::optional<std::vector<OUString> >(
            std::vector<OUString> ());
     //only add the path if not already present
    std::vector<OUString>::const_iterator it =
diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx
index ece4dd2..df00365 100644
--- a/jvmfwk/source/fwkbase.cxx
+++ b/jvmfwk/source/fwkbase.cxx
@@ -113,7 +113,7 @@ VendorSettings::VendorSettings():
    }
}

boost::optional<VersionInfo> VendorSettings::getVersionInformation(const OUString & sVendor) const
o3tl::optional<VersionInfo> VendorSettings::getVersionInformation(const OUString & sVendor) const
{
    OSL_ASSERT(!sVendor.isEmpty());
    OString osVendor = OUStringToOString(sVendor, RTL_TEXTENCODING_UTF8);
diff --git a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
index cac8356..fec03e0 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-application-window.cxx
@@ -24,7 +24,7 @@
#include "gtv-lok-dialog.hxx"

#include <boost/property_tree/json_parser.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace {

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx b/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx
index c283490..a332d96 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-calc-header-bar.cxx
@@ -19,7 +19,7 @@

#include <map>
#include <boost/property_tree/json_parser.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace {

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
index e164912..bcee979 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-lokdocview-signal-handlers.cxx
@@ -18,7 +18,7 @@
#include "gtv-lok-dialog.hxx"

#include <boost/property_tree/json_parser.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <iostream>

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx
index cdbb236..25f7d78 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-main-toolbar.cxx
@@ -20,7 +20,7 @@
#include <memory>

#include <boost/property_tree/json_parser.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace {

diff --git a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
index 288d56d..1b0233f 100644
--- a/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtv-signal-handlers.cxx
@@ -20,7 +20,7 @@
#include <vector>

#include <boost/property_tree/json_parser.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

void btn_clicked(GtkWidget* pButton, gpointer)
{
@@ -89,7 +89,7 @@ void doPaste(GtkWidget* pButton, gpointer /*pItem*/)
        g_free(pTargets);
    }

    boost::optional<GdkAtom> oTarget;
    o3tl::optional<GdkAtom> oTarget;
    std::string aTargetName;

    std::vector<std::string> aPreferredNames =
diff --git a/libreofficekit/qa/tilebench/tilebench.cxx b/libreofficekit/qa/tilebench/tilebench.cxx
index aceed1fa..8802cb8 100644
--- a/libreofficekit/qa/tilebench/tilebench.cxx
+++ b/libreofficekit/qa/tilebench/tilebench.cxx
@@ -23,7 +23,7 @@
#include <LibreOfficeKit/LibreOfficeKit.hxx>

#include <boost/property_tree/json_parser.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

using namespace lok;

diff --git a/officecfg/registry/cppheader.xsl b/officecfg/registry/cppheader.xsl
index 9a8042b..2280df5 100644
--- a/officecfg/registry/cppheader.xsl
+++ b/officecfg/registry/cppheader.xsl
@@ -78,7 +78,7 @@
    <xsl:if test=".//prop or .//set">
      <xsl:if
          test=".//prop[count(@oor:nillable) = 0 or @oor:nillable = 'true']">
        <xsl:text>#include "boost/optional.hpp"&#xA;</xsl:text>
        <xsl:text>#include "o3tl/optional.hxx"&#xA;</xsl:text>
      </xsl:if>
      <xsl:if test=".//prop/@oor:type = 'oor:any'">
        <xsl:text>#include "com/sun/star/uno/Any.hxx"&#xA;</xsl:text>
@@ -198,7 +198,7 @@
    <xsl:value-of select="$name"/>
    <xsl:text>, </xsl:text>
    <xsl:if test="not(@oor:nillable = 'false')">
      <xsl:text>boost::optional&lt;</xsl:text>
      <xsl:text>o3tl::optional&lt;</xsl:text>
    </xsl:if>
    <xsl:choose>
      <xsl:when test="@oor:type='oor:any'">
diff --git a/oox/inc/drawingml/table/tablestylepart.hxx b/oox/inc/drawingml/table/tablestylepart.hxx
index 2a03339..056b79b 100644
--- a/oox/inc/drawingml/table/tablestylepart.hxx
+++ b/oox/inc/drawingml/table/tablestylepart.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_OOX_DRAWINGML_TABLE_TABLESTYLEPART_HXX

#include <rtl/ustring.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <oox/drawingml/color.hxx>
#include <drawingml/textfont.hxx>
#include <oox/drawingml/shape.hxx>
@@ -40,8 +40,8 @@ public:
    TableStylePart();

    ::oox::drawingml::Color&            getTextColor(){ return maTextColor; }
    ::boost::optional< bool >&          getTextBoldStyle(){ return maTextBoldStyle; }
    ::boost::optional< bool >&          getTextItalicStyle(){ return maTextItalicStyle; }
    ::o3tl::optional< bool >&          getTextBoldStyle(){ return maTextBoldStyle; }
    ::o3tl::optional< bool >&          getTextItalicStyle(){ return maTextItalicStyle; }
    ::oox::drawingml::TextFont&         getAsianFont(){ return maAsianFont; }
    ::oox::drawingml::TextFont&         getComplexFont(){ return maComplexFont; }
    ::oox::drawingml::TextFont&         getSymbolFont(){ return maSymbolFont; }
@@ -55,8 +55,8 @@ public:
private:

    ::oox::drawingml::Color             maTextColor;
    ::boost::optional< bool >           maTextBoldStyle;
    ::boost::optional< bool >           maTextItalicStyle;
    ::o3tl::optional< bool >           maTextBoldStyle;
    ::o3tl::optional< bool >           maTextItalicStyle;
    ::oox::drawingml::TextFont          maAsianFont;
    ::oox::drawingml::TextFont          maComplexFont;
    ::oox::drawingml::TextFont          maSymbolFont;
diff --git a/oox/inc/drawingml/textbodyproperties.hxx b/oox/inc/drawingml/textbodyproperties.hxx
index 785f117..4c378cf 100644
--- a/oox/inc/drawingml/textbodyproperties.hxx
+++ b/oox/inc/drawingml/textbodyproperties.hxx
@@ -23,7 +23,7 @@
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <oox/helper/helper.hxx>
#include <oox/helper/propertymap.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace oox {
namespace drawingml {
@@ -35,11 +35,11 @@ struct TextBodyProperties
    OptValue< sal_Int32 >                           moRotation;
    bool                                            mbAnchorCtr;
    OptValue< sal_Int32 >                           moVert;
    boost::optional< sal_Int32 >                    moInsets[4];
    boost::optional< sal_Int32 >                    moTextOffUpper;
    boost::optional< sal_Int32 >                    moTextOffLeft;
    boost::optional< sal_Int32 >                    moTextOffLower;
    boost::optional< sal_Int32 >                    moTextOffRight;
    o3tl::optional< sal_Int32 >                    moInsets[4];
    o3tl::optional< sal_Int32 >                    moTextOffUpper;
    o3tl::optional< sal_Int32 >                    moTextOffLeft;
    o3tl::optional< sal_Int32 >                    moTextOffLower;
    o3tl::optional< sal_Int32 >                    moTextOffRight;
    css::drawing::TextVerticalAdjust                meVA;
    OUString                                        msPrst;
    /// Number of requested columns.
diff --git a/oox/inc/drawingml/textparagraphproperties.hxx b/oox/inc/drawingml/textparagraphproperties.hxx
index 5b8093b..6b9d93c 100644
--- a/oox/inc/drawingml/textparagraphproperties.hxx
+++ b/oox/inc/drawingml/textparagraphproperties.hxx
@@ -27,7 +27,7 @@
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <drawingml/textfont.hxx>
#include <drawingml/textspacing.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace com { namespace sun { namespace star {
    namespace graphic { class XGraphic; }
@@ -90,10 +90,10 @@ public:

    TextSpacing&                        getParaTopMargin() { return maParaTopMargin; }
    TextSpacing&                        getParaBottomMargin() { return maParaBottomMargin; }
    boost::optional< sal_Int32 >&       getParaLeftMargin(){ return moParaLeftMargin; }
    boost::optional< sal_Int32 >&       getFirstLineIndentation(){ return moFirstLineIndentation; }
    o3tl::optional< sal_Int32 >&       getParaLeftMargin(){ return moParaLeftMargin; }
    o3tl::optional< sal_Int32 >&       getFirstLineIndentation(){ return moFirstLineIndentation; }

    boost::optional< css::style::ParagraphAdjust >&       getParaAdjust() { return moParaAdjust; }
    o3tl::optional< css::style::ParagraphAdjust >&       getParaAdjust() { return moParaAdjust; }
    void                                setParaAdjust( css::style::ParagraphAdjust nParaAdjust ) { moParaAdjust = nParaAdjust; }

    TextSpacing&                        getLineSpacing() { return maLineSpacing; }
@@ -124,9 +124,9 @@ protected:
    BulletList                      maBulletList;
    TextSpacing                     maParaTopMargin;
    TextSpacing                     maParaBottomMargin;
    boost::optional< sal_Int32 >    moParaLeftMargin;
    boost::optional< sal_Int32 >    moFirstLineIndentation;
    boost::optional< css::style::ParagraphAdjust >    moParaAdjust;
    o3tl::optional< sal_Int32 >    moParaLeftMargin;
    o3tl::optional< sal_Int32 >    moFirstLineIndentation;
    o3tl::optional< css::style::ParagraphAdjust >    moParaAdjust;
    sal_Int16                       mnLevel;
    TextSpacing                     maLineSpacing;
};
diff --git a/oox/inc/pch/precompiled_oox.hxx b/oox/inc/pch/precompiled_oox.hxx
index 17c3862..e261a0a 100644
--- a/oox/inc/pch/precompiled_oox.hxx
+++ b/oox/inc/pch/precompiled_oox.hxx
@@ -40,7 +40,7 @@
#include <utility>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 816711b..2b6ecf6 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1167,7 +1167,7 @@ Reference< XShape > const & Shape::createAndInsert(
                    xPropertySet->setPropertyValue(aGrabBagPropName, uno::makeAny(aGrabBag));
                }
                // TextFrames have ShadowFormat, not individual shadow properties.
                boost::optional<sal_Int32> oShadowDistance;
                o3tl::optional<sal_Int32> oShadowDistance;
                if (aShapeProps.hasProperty(PROP_ShadowXDistance))
                {
                    oShadowDistance = aShapeProps.getProperty(PROP_ShadowXDistance).get<sal_Int32>();
@@ -1178,7 +1178,7 @@ Reference< XShape > const & Shape::createAndInsert(
                    // There is a single 'dist' attribute, so no need to count the avg of x and y.
                    aShapeProps.erase(PROP_ShadowYDistance);
                }
                boost::optional<sal_Int32> oShadowColor;
                o3tl::optional<sal_Int32> oShadowColor;
                if (aShapeProps.hasProperty(PROP_ShadowColor))
                {
                    oShadowColor = aShapeProps.getProperty(PROP_ShadowColor).get<sal_Int32>();
diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx
index 351ead9..1043323 100644
--- a/oox/source/drawingml/textparagraphproperties.cxx
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -409,8 +409,8 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p
    if ( maParaBottomMargin.bHasValue || bPushDefaultValues )
        aPropSet.setProperty( PROP_ParaBottomMargin, maParaBottomMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 12.0 ) ) );

    boost::optional< sal_Int32 > noParaLeftMargin( moParaLeftMargin );
    boost::optional< sal_Int32 > noFirstLineIndentation( moFirstLineIndentation );
    o3tl::optional< sal_Int32 > noParaLeftMargin( moParaLeftMargin );
    o3tl::optional< sal_Int32 > noFirstLineIndentation( moFirstLineIndentation );

    if ( nNumberingType != NumberingType::NUMBER_NONE )
    {
diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx
index fee3d8c..f194d04 100644
--- a/oox/source/drawingml/textparagraphpropertiescontext.cxx
+++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx
@@ -91,7 +91,7 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H
    if ( rAttribs.hasAttribute( XML_indent ) )
    {
        sValue = rAttribs.getString( XML_indent ).get();
        mrTextParagraphProperties.getFirstLineIndentation() = boost::optional< sal_Int32 >( sValue.isEmpty() ? 0 : GetCoordinate( sValue ) );
        mrTextParagraphProperties.getFirstLineIndentation() = o3tl::optional< sal_Int32 >( sValue.isEmpty() ? 0 : GetCoordinate( sValue ) );
    }

  // ST_TextIndentLevelType
@@ -114,7 +114,7 @@ TextParagraphPropertiesContext::TextParagraphPropertiesContext( ContextHandler2H
    if ( rAttribs.hasAttribute( XML_marL ) )
    {
        sValue = rAttribs.getString( XML_marL ).get();
        mrTextParagraphProperties.getParaLeftMargin() = boost::optional< sal_Int32 >( sValue.isEmpty() ? 0 : GetCoordinate( sValue ) );
        mrTextParagraphProperties.getParaLeftMargin() = o3tl::optional< sal_Int32 >( sValue.isEmpty() ? 0 : GetCoordinate( sValue ) );
    }

    // ParaRightMargin
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index cd9afdc..cf637ea 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -24,7 +24,7 @@
#include <oox/token/tokens.hxx>
#include <oox/drawingml/shape.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

using namespace com::sun::star;

@@ -96,7 +96,7 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
                {
                    // Handle inset attributes for Writer textframes.
                    sal_Int32 aInsets[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
                    boost::optional<sal_Int32> oInsets[4];
                    o3tl::optional<sal_Int32> oInsets[4];
                    for (std::size_t i = 0; i < SAL_N_ELEMENTS(aInsets); ++i)
                    {
                        OptValue<OUString> oValue = rAttribs.getString(aInsets[i]);
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index e27700f..604c2e8 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -20,7 +20,7 @@
#include <algorithm>
#include <cassert>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <o3tl/safeint.hxx>
#include <oox/vml/vmlshape.hxx>
@@ -527,7 +527,7 @@ void ShapeBase::convertShapeProperties( const Reference< XShape >& rxShape ) con
            aPropMap.erase(PROP_FillTransparence);
        }
        // And no LineColor property; individual borders can have colors and widths
        boost::optional<sal_Int32> oLineWidth;
        o3tl::optional<sal_Int32> oLineWidth;
        if (maTypeModel.maStrokeModel.moWeight.has())
            oLineWidth = ConversionHelper::decodeMeasureToHmm(
                rGraphicHelper, maTypeModel.maStrokeModel.moWeight.get(), 0, false, false);
@@ -661,7 +661,7 @@ static void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rType
Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const
{
    awt::Rectangle aShapeRect(rShapeRect);
    boost::optional<sal_Int32> oRotation;
    o3tl::optional<sal_Int32> oRotation;
    bool bFlipX = false, bFlipY = false;
    if (!maTypeModel.maRotation.isEmpty())
        oRotation = ConversionHelper::decodeRotation(maTypeModel.maRotation);
diff --git a/pch/inc/pch/precompiled_system.hxx b/pch/inc/pch/precompiled_system.hxx
index 8e53109..526ab6d 100644
--- a/pch/inc/pch/precompiled_system.hxx
+++ b/pch/inc/pch/precompiled_system.hxx
@@ -33,8 +33,8 @@
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/random_access_index.hpp>
#include <boost/operators.hpp>
#include <boost/optional.hpp>
#include <boost/optional/optional.hpp>
#include <o3tl/optional.hxx>
#include <o3tl/optional.hxx>
#include <boost/property_tree/json_parser.hpp>
#include <boost/rational.hpp>
#include <boost/version.hpp>
diff --git a/reportdesign/inc/pch/precompiled_rpt.hxx b/reportdesign/inc/pch/precompiled_rpt.hxx
index b10f974..5cecaca 100644
--- a/reportdesign/inc/pch/precompiled_rpt.hxx
+++ b/reportdesign/inc/pch/precompiled_rpt.hxx
@@ -49,7 +49,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/reportdesign/inc/pch/precompiled_rptui.hxx b/reportdesign/inc/pch/precompiled_rptui.hxx
index 064d9a9..47491a2 100644
--- a/reportdesign/inc/pch/precompiled_rptui.hxx
+++ b/reportdesign/inc/pch/precompiled_rptui.hxx
@@ -54,7 +54,7 @@
#include <utility>
#include <vector>
#include <boost/intrusive_ptr.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx
index b94e1f9..b612f4d 100644
--- a/sax/source/tools/converter.cxx
+++ b/sax/source/tools/converter.cxx
@@ -24,7 +24,7 @@
#include <com/sun/star/util/Date.hpp>
#include <com/sun/star/util/Duration.hpp>
#include <com/sun/star/util/Time.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <rtl/ustrbuf.hxx>
#include <rtl/math.hxx>
@@ -1595,7 +1595,7 @@ static bool lcl_parseDate(
static bool lcl_parseDateTime(
                util::Date *const pDate, util::DateTime & rDateTime,
                bool & rbDateTime,
                boost::optional<sal_Int16> *const pTimeZoneOffset,
                o3tl::optional<sal_Int16> *const pTimeZoneOffset,
                const OUString & rString,
                bool const bIgnoreInvalidOrMissingDate)
{
@@ -1831,7 +1831,7 @@ bool Converter::parseTimeOrDateTime(
bool Converter::parseDateOrDateTime(
                util::Date *const pDate, util::DateTime & rDateTime,
                bool & rbDateTime,
                boost::optional<sal_Int16> *const pTimeZoneOffset,
                o3tl::optional<sal_Int16> *const pTimeZoneOffset,
                const OUString & rString )
{
    return lcl_parseDateTime(
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index fcaef91..fc15a98 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -32,7 +32,7 @@
#include <tools/link.hxx>
#include <tools/solar.h>
#include <unotools/options.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include "global.hxx"
#include "bigrange.hxx"
#include "scdllapi.h"
@@ -849,7 +849,7 @@ class SAL_DLLPUBLIC_RTTI ScChangeTrack : public utl::ConfigurationListener
    ScChangeActionLinkEntry*    pLinkInsertRow;
    ScChangeActionLinkEntry*    pLinkInsertTab;
    ScChangeActionLinkEntry*    pLinkMove;
    boost::optional<ScChangeTrackMsgInfo> xBlockModifyMsg;
    o3tl::optional<ScChangeTrackMsgInfo> xBlockModifyMsg;
    ScDocument*             pDoc;
    sal_uLong               nActionMax;
    sal_uLong               nGeneratedMin;
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 861ff5e..dea9de5 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -268,7 +268,7 @@ public:

    virtual void SetParent(ScConditionalFormat* pParent) override;

    boost::optional<Color> GetColor(const ScAddress& rAddr) const;
    o3tl::optional<Color> GetColor(const ScAddress& rAddr) const;
    void AddEntry(ScColorScaleEntry* pEntry);

    virtual void UpdateReference( sc::RefUpdateContext& rCxt ) override;
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 40cfdff..4ddb17c 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -37,7 +37,7 @@
#include <tools/date.hxx>
#include <tools/link.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <map>
#include <memory>
#include <set>
@@ -216,7 +216,7 @@ struct ScCondFormatData
    ScCondFormatData(ScCondFormatData&&);
    ~ScCondFormatData();

    boost::optional<Color> mxColorScale;
    o3tl::optional<Color> mxColorScale;
    std::unique_ptr<ScDataBarInfo> pDataBar;
    std::unique_ptr<ScIconSetInfo> pIconSet;
    OUString aStyleName;
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 49cb240..e7c9d0b 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -32,7 +32,7 @@

#include <unordered_map>
#include <unordered_set>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace com { namespace sun { namespace star { namespace sheet {
    class XDimensionsSupplier;
@@ -52,7 +52,7 @@ class ScDPSaveMember
{
private:
    OUString aName;
    boost::optional<OUString> mpLayoutName; // custom name to be displayed in the table.
    o3tl::optional<OUString> mpLayoutName; // custom name to be displayed in the table.
    sal_uInt16 nVisibleMode;
    sal_uInt16 nShowDetailsMode;

@@ -79,7 +79,7 @@ public:
    void SetName( const OUString& rNew ); // used if the source member was renamed (groups)

    SC_DLLPUBLIC void SetLayoutName( const OUString& rName );
    SC_DLLPUBLIC const boost::optional<OUString> & GetLayoutName() const;
    SC_DLLPUBLIC const o3tl::optional<OUString> & GetLayoutName() const;
    void RemoveLayoutName();

    void WriteToSource( const css::uno::Reference<css::uno::XInterface>& xMember,
@@ -94,8 +94,8 @@ class SC_DLLPUBLIC ScDPSaveDimension
{
private:
    OUString aName;
    boost::optional<OUString> mpLayoutName;
    boost::optional<OUString> mpSubtotalName;
    o3tl::optional<OUString> mpLayoutName;
    o3tl::optional<OUString> mpSubtotalName;
    bool bIsDataLayout;
    bool bDupFlag;
    css::sheet::DataPilotFieldOrientation nOrientation;
@@ -170,10 +170,10 @@ public:
        { return nUsedHierarchy; }

    void SetLayoutName(const OUString& rName);
    const boost::optional<OUString> & GetLayoutName() const;
    const o3tl::optional<OUString> & GetLayoutName() const;
    void RemoveLayoutName();
    void SetSubtotalName(const OUString& rName);
    const boost::optional<OUString> & GetSubtotalName() const;
    const o3tl::optional<OUString> & GetSubtotalName() const;
    void RemoveSubtotalName();

    bool IsMemberNameInUse(const OUString& rName) const;
@@ -252,7 +252,7 @@ private:
     *  created. */
    bool mbDimensionMembersBuilt;

    boost::optional<OUString> mpGrandTotalName;
    o3tl::optional<OUString> mpGrandTotalName;
    mutable std::unique_ptr<DimOrderType> mpDimOrder; // dimension order for row and column dimensions, to traverse result tree.

public:
@@ -265,7 +265,7 @@ public:
    bool operator== ( const ScDPSaveData& r ) const;

    SC_DLLPUBLIC void SetGrandTotalName(const OUString& rName);
    SC_DLLPUBLIC const boost::optional<OUString> & GetGrandTotalName() const;
    SC_DLLPUBLIC const o3tl::optional<OUString> & GetGrandTotalName() const;

    const DimsType& GetDimensions() const { return m_DimList; }

diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index a5eb7f7..a6ddf33 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -48,7 +48,7 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace com { namespace sun { namespace star {
    namespace sheet {
@@ -109,7 +109,7 @@ private:
    bool                    bResultOverflow;
    bool                    bPageFiltered;      // set if page field filters have been applied to cache table

    boost::optional<OUString> mpGrandTotalName;
    o3tl::optional<OUString> mpGrandTotalName;

    void                    CreateRes_Impl();
    void                    FillMemberResults();
@@ -144,7 +144,7 @@ public:
    ScDPTableData*          GetData()       { return pData; }
    const ScDPTableData*    GetData() const { return pData; }

    const boost::optional<OUString> &
    const o3tl::optional<OUString> &
                            GetGrandTotalName() const;

    css::sheet::DataPilotFieldOrientation
@@ -268,8 +268,8 @@ class ScDPDimension : public cppu::WeakImplHelper<
    rtl::Reference<ScDPHierarchies> mxHierarchies;
    ScGeneralFunction   nFunction;
    OUString            aName;              // if empty, take from source
    boost::optional<OUString> mpLayoutName;
    boost::optional<OUString> mpSubtotalName;
    o3tl::optional<OUString> mpLayoutName;
    o3tl::optional<OUString> mpSubtotalName;
    long                nSourceDim;         // >=0 if dup'ed
    css::sheet::DataPilotFieldReference
                        aReferenceValue;    // settings for "show data as" / "displayed value"
@@ -291,8 +291,8 @@ public:
    ScDPDimension*          CreateCloneObject();
    ScDPHierarchies*        GetHierarchiesObject();

    const boost::optional<OUString> & GetLayoutName() const;
    const boost::optional<OUString> & GetSubtotalName() const;
    const o3tl::optional<OUString> & GetLayoutName() const;
    const o3tl::optional<OUString> & GetSubtotalName() const;

                            // XNamed
    virtual OUString SAL_CALL getName() override;
@@ -604,7 +604,7 @@ private:
    long const      nLev;

    SCROW const     mnDataId;
    boost::optional<OUString> mpLayoutName;
    o3tl::optional<OUString> mpLayoutName;

    sal_Int32       nPosition;          // manual sorting
    bool            bVisible;
@@ -622,7 +622,7 @@ public:
    SCROW GetItemDataId() const { return mnDataId; }
    bool IsNamedItem(SCROW nIndex) const;

    const boost::optional<OUString> & GetLayoutName() const;
    const o3tl::optional<OUString> & GetLayoutName() const;
    long GetDim() const { return nDim;}

    sal_Int32               Compare( const ScDPMember& rOther ) const;      // visible order
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 86d579b..a3e4949 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -74,7 +74,7 @@ public:
    static std::unique_ptr<EditTextObject> Clone( const EditTextObject& rSrc, ScDocument& rDestDoc );

    static OUString GetCellFieldValue(
        const SvxFieldData& rFieldData, const ScDocument* pDoc, boost::optional<Color>* ppTextColor );
        const SvxFieldData& rFieldData, const ScDocument* pDoc, o3tl::optional<Color>* ppTextColor );

public:
                ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ,
@@ -186,7 +186,7 @@ public:
    void SetExecuteURL(bool bSet)    { bExecuteURL = bSet; }

    virtual void    FieldClicked( const SvxFieldItem& rField ) override;
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) override;
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor ) override;
};

// 1/100 mm
@@ -223,7 +223,7 @@ private:

public:
    ScHeaderEditEngine( SfxItemPool* pEnginePool );
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) override;
    virtual OUString CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor ) override;

    void SetNumType(SvxNumType eNew)                { aData.eNumType = eNew; }
    void SetData(const ScHeaderFieldData& rNew)     { aData = rNew; }
diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx
index 850fb47..d15537c 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -28,7 +28,7 @@
#include "colorscale.hxx"
#include "cellvalue.hxx"
#include <o3tl/typed_flags_set.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class SfxItemSet;
class SvxBrushItem;
@@ -134,7 +134,7 @@ struct CellInfo

    const ScPatternAttr*        pPatternAttr;
    const SfxItemSet*           pConditionSet;
    boost::optional<Color>      mxColorScale;
    o3tl::optional<Color>      mxColorScale;
    std::unique_ptr<const ScDataBarInfo> pDataBar;
    std::unique_ptr<const ScIconSetInfo> pIconSet;

diff --git a/sc/inc/fonthelper.hxx b/sc/inc/fonthelper.hxx
index abc2bf5..f3ecf2b 100644
--- a/sc/inc/fonthelper.hxx
+++ b/sc/inc/fonthelper.hxx
@@ -11,7 +11,7 @@
#define INCLUDED_SC_INC_FONTHELPER_HXX

#include "scdllapi.h"
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <tools/fontenum.hxx>
#include <tools/color.hxx>
#include <vcl/fntstyle.hxx>
@@ -21,20 +21,20 @@ class SvxFontItem;

struct SC_DLLPUBLIC ScDxfFont
{
    boost::optional<const SvxFontItem*> pFontAttr;
    boost::optional<sal_uInt32> nFontHeight;
    boost::optional<FontWeight> eWeight;
    boost::optional<FontItalic> eItalic;
    boost::optional<FontLineStyle> eUnder;
    boost::optional<FontLineStyle> eOver;
    boost::optional<bool> bWordLine;
    boost::optional<FontStrikeout> eStrike;
    boost::optional<bool> bOutline;
    boost::optional<bool> bShadow;
    boost::optional<FontEmphasisMark> eEmphasis;
    boost::optional<FontRelief> eRelief;
    boost::optional<Color> aColor;
    boost::optional<LanguageType> eLang;
    o3tl::optional<const SvxFontItem*> pFontAttr;
    o3tl::optional<sal_uInt32> nFontHeight;
    o3tl::optional<FontWeight> eWeight;
    o3tl::optional<FontItalic> eItalic;
    o3tl::optional<FontLineStyle> eUnder;
    o3tl::optional<FontLineStyle> eOver;
    o3tl::optional<bool> bWordLine;
    o3tl::optional<FontStrikeout> eStrike;
    o3tl::optional<bool> bOutline;
    o3tl::optional<bool> bShadow;
    o3tl::optional<FontEmphasisMark> eEmphasis;
    o3tl::optional<FontRelief> eRelief;
    o3tl::optional<Color> aColor;
    o3tl::optional<LanguageType> eLang;

    bool isEmpty() const
    {
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx
index cb7f8f7..10d57b2 100644
--- a/sc/inc/funcdesc.hxx
+++ b/sc/inc/funcdesc.hxx
@@ -27,7 +27,7 @@
#include <formula/IFunctionDescription.hxx>
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <map>
#include <memory>

@@ -207,8 +207,8 @@ public:
        ParameterFlags() : bOptional(false) {}
    };

    boost::optional<OUString> mxFuncName;         /**< Function name */
    boost::optional<OUString> mxFuncDesc;         /**< Description of function */
    o3tl::optional<OUString> mxFuncName;         /**< Function name */
    o3tl::optional<OUString> mxFuncDesc;         /**< Description of function */
    std::vector<OUString> maDefArgNames;          /**< Parameter name(s) */
    std::vector<OUString> maDefArgDescs;          /**< Description(s) of parameter(s) */
    ParameterFlags       *pDefArgFlags;           /**< Flags for each parameter */
diff --git a/sc/inc/paramisc.hxx b/sc/inc/paramisc.hxx
index 0c8432f..992c4fc 100644
--- a/sc/inc/paramisc.hxx
+++ b/sc/inc/paramisc.hxx
@@ -21,13 +21,13 @@
#define INCLUDED_SC_INC_PARAMISC_HXX

#include "address.hxx"
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

struct ScSolveParam
{
    ScAddress                   aRefFormulaCell;
    ScAddress                   aRefVariableCell;
    boost::optional<OUString>   pStrTargetVal;
    o3tl::optional<OUString>   pStrTargetVal;

    ScSolveParam();
    ScSolveParam( const ScSolveParam& r );
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index 19c4df0..7c6b605 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -51,7 +51,7 @@ enum ScAutoFontColorMode

class SC_DLLPUBLIC ScPatternAttr final : public SfxSetItem
{
    boost::optional<OUString>  pName;
    o3tl::optional<OUString>  pName;
    ScStyleSheet*              pStyle;
    sal_uInt64                 mnKey;
public:
diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx
index bb38064..04a20a9 100644
--- a/sc/inc/pch/precompiled_sc.hxx
+++ b/sc/inc/pch/precompiled_sc.hxx
@@ -52,8 +52,8 @@
#include <vector>
#include <boost/functional/hash.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/optional.hpp>
#include <boost/optional/optional.hpp>
#include <o3tl/optional.hxx>
#include <o3tl/optional.hxx>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
diff --git a/sc/inc/pch/precompiled_scfilt.hxx b/sc/inc/pch/precompiled_scfilt.hxx
index aa18ffa..d13e9f4 100644
--- a/sc/inc/pch/precompiled_scfilt.hxx
+++ b/sc/inc/pch/precompiled_scfilt.hxx
@@ -44,7 +44,7 @@
#include <unordered_set>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/sc/inc/sheetevents.hxx b/sc/inc/sheetevents.hxx
index 3fb0e28..fb9d5df 100644
--- a/sc/inc/sheetevents.hxx
+++ b/sc/inc/sheetevents.hxx
@@ -23,7 +23,7 @@
#include <rtl/ustring.hxx>
#include <memory>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

enum class ScSheetEventId {
    FOCUS, UNFOCUS, SELECT, DOUBLECLICK, RIGHTCLICK, CHANGE, CALCULATE, COUNT,
@@ -32,7 +32,7 @@ enum class ScSheetEventId {

class ScSheetEvents
{
    std::unique_ptr<boost::optional<OUString>[]> mpScriptNames;
    std::unique_ptr<o3tl::optional<OUString>[]> mpScriptNames;

    void        Clear();

diff --git a/sc/qa/unit/pivottable_filters_test.cxx b/sc/qa/unit/pivottable_filters_test.cxx
index 17f637b..1c7d57a 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -2432,7 +2432,7 @@ void ScPivotTableFiltersTest::testTdf112106()
    // Check that we have an existing data layout dimension
    const ScDPSaveDimension* pDim = pSaveData->GetExistingDataLayoutDimension();
    CPPUNIT_ASSERT(pDim);
    const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName();
    const o3tl::optional<OUString> & pLayoutName = pDim->GetLayoutName();
    CPPUNIT_ASSERT(pLayoutName);
    CPPUNIT_ASSERT_EQUAL(ScResId(STR_PIVOT_DATA), (*pLayoutName));

diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index 31e83f2..e282ca7 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -585,17 +585,17 @@ double ScColorScaleFormat::CalcValue(double nMin, double nMax, const ScColorScal
    return (*itr)->GetValue();
}

boost::optional<Color> ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
o3tl::optional<Color> ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const
{
    ScRefCellValue rCell(*mpDoc, rAddr);
    if(!rCell.hasNumeric())
        return boost::optional<Color>();
        return o3tl::optional<Color>();

    // now we have for sure a value
    double nVal = rCell.getValue();

    if (maColorScales.size() < 2)
        return boost::optional<Color>();
        return o3tl::optional<Color>();

    double nMin = std::numeric_limits<double>::max();
    double nMax = std::numeric_limits<double>::min();
@@ -603,7 +603,7 @@ boost::optional<Color> ScColorScaleFormat::GetColor( const ScAddress& rAddr ) co

    // this check is for safety
    if(nMin >= nMax)
        return boost::optional<Color>();
        return o3tl::optional<Color>();

    ScColorScaleEntries::const_iterator itr = begin();
    double nValMin = CalcValue(nMin, nMax, itr);
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 28de482..6f653f8 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1314,7 +1314,7 @@ public:
    bool operator() (const ScDPSaveDimension* pDim) const
    {
        // Layout name takes precedence.
        const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName();
        const o3tl::optional<OUString> & pLayoutName = pDim->GetLayoutName();
        if (pLayoutName && ScGlobal::pCharClass->uppercase(*pLayoutName) == maName)
            return true;

diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 4977643..109e9da 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -120,7 +120,7 @@ void ScDPSaveMember::SetLayoutName( const OUString& rName )
    mpLayoutName = rName;
}

const boost::optional<OUString> & ScDPSaveMember::GetLayoutName() const
const o3tl::optional<OUString> & ScDPSaveMember::GetLayoutName() const
{
    return mpLayoutName;
}
@@ -355,7 +355,7 @@ void ScDPSaveDimension::SetSubtotalName(const OUString& rName)
    mpSubtotalName = rName;
}

const boost::optional<OUString> & ScDPSaveDimension::GetSubtotalName() const
const o3tl::optional<OUString> & ScDPSaveDimension::GetSubtotalName() const
{
    return mpSubtotalName;
}
@@ -371,7 +371,7 @@ bool ScDPSaveDimension::IsMemberNameInUse(const OUString& rName) const
        if (rName.equalsIgnoreAsciiCase(pMem->GetName()))
            return true;

        const boost::optional<OUString> & pLayoutName = pMem->GetLayoutName();
        const o3tl::optional<OUString> & pLayoutName = pMem->GetLayoutName();
        return pLayoutName && rName.equalsIgnoreAsciiCase(*pLayoutName);
    });
}
@@ -381,7 +381,7 @@ void ScDPSaveDimension::SetLayoutName(const OUString& rName)
    mpLayoutName = rName;
}

const boost::optional<OUString> & ScDPSaveDimension::GetLayoutName() const
const o3tl::optional<OUString> & ScDPSaveDimension::GetLayoutName() const
{
    return mpLayoutName;
}
@@ -502,7 +502,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
        if (mpLayoutName)
            ScUnoHelpFunctions::SetOptionalPropertyValue(xDimProp, SC_UNO_DP_LAYOUTNAME, *mpLayoutName);

        const boost::optional<OUString> & pSubTotalName = GetSubtotalName();
        const o3tl::optional<OUString> & pSubTotalName = GetSubtotalName();
        if (pSubTotalName)
            // Custom subtotal name, with '?' being replaced by the visible field name later.
            ScUnoHelpFunctions::SetOptionalPropertyValue(xDimProp, SC_UNO_DP_FIELD_SUBTOTALNAME, *pSubTotalName);
@@ -768,7 +768,7 @@ void ScDPSaveData::SetGrandTotalName(const OUString& rName)
    mpGrandTotalName = rName;
}

const boost::optional<OUString> & ScDPSaveData::GetGrandTotalName() const
const o3tl::optional<OUString> & ScDPSaveData::GetGrandTotalName() const
{
    return mpGrandTotalName;
}
@@ -1054,7 +1054,7 @@ void ScDPSaveData::WriteToSource( const uno::Reference<sheet::XDimensionsSupplie
            // no error
        }

        const boost::optional<OUString> & pGrandTotalName = GetGrandTotalName();
        const o3tl::optional<OUString> & pGrandTotalName = GetGrandTotalName();
        if (pGrandTotalName)
            ScUnoHelpFunctions::SetOptionalPropertyValue(xSourceProp, SC_UNO_DP_GRANDTOTAL_NAME, *pGrandTotalName);
    }
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 43fb34e..9c2b453 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -857,7 +857,7 @@ OUString ScDPResultData::GetMeasureString(long nMeasure, bool bForce, ScSubTotal
        const ScDPDimension* pDataDim = mrSource.GetDataDimension(nMeasure);
        if (pDataDim)
        {
            const boost::optional<OUString> & pLayoutName = pDataDim->GetLayoutName();
            const o3tl::optional<OUString> & pLayoutName = pDataDim->GetLayoutName();
            if (pLayoutName)
                return *pLayoutName;
        }
@@ -1379,7 +1379,7 @@ void ScDPResultMember::FillMemberResults(
    const ScDPMember* pMemberDesc = GetDPMember();
    if (pMemberDesc)
    {
        const boost::optional<OUString> & pLayoutName = pMemberDesc->GetLayoutName();
        const o3tl::optional<OUString> & pLayoutName = pMemberDesc->GetLayoutName();
        if (pLayoutName)
        {
            aCaption = *pLayoutName;
@@ -1481,7 +1481,7 @@ void ScDPResultMember::FillMemberResults(
                    if (pMemberDesc)
                    {
                        // single data field layout.
                        const boost::optional<OUString> & pSubtotalName = pParentDim->GetSubtotalName();
                        const o3tl::optional<OUString> & pSubtotalName = pParentDim->GetSubtotalName();
                        if (pSubtotalName)
                            aSubStr = lcl_parseSubtotalName(*pSubtotalName, aCaption);
                        pArray[rPos].Flags &= ~sheet::MemberResultFlags::GRANDTOTAL;
@@ -1489,7 +1489,7 @@ void ScDPResultMember::FillMemberResults(
                    else
                    {
                        // root member - subtotal (grand total?) for multi-data field layout.
                        const boost::optional<OUString> & pGrandTotalName = pResultData->GetSource().GetGrandTotalName();
                        const o3tl::optional<OUString> & pGrandTotalName = pResultData->GetSource().GetGrandTotalName();
                        if (pGrandTotalName)
                            aSubStr = *pGrandTotalName;
                        pArray[rPos].Flags |= sheet::MemberResultFlags::GRANDTOTAL;
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index caadfb5..de6e778 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -110,7 +110,7 @@ ScDPSource::~ScDPSource()
    pResData.reset();
}

const boost::optional<OUString> & ScDPSource::GetGrandTotalName() const
const o3tl::optional<OUString> & ScDPSource::GetGrandTotalName() const
{
    return mpGrandTotalName;
}
@@ -1288,12 +1288,12 @@ ScDPHierarchies* ScDPDimension::GetHierarchiesObject()
    return mxHierarchies.get();
}

const boost::optional<OUString> & ScDPDimension::GetLayoutName() const
const o3tl::optional<OUString> & ScDPDimension::GetLayoutName() const
{
    return mpLayoutName;
}

const boost::optional<OUString> & ScDPDimension::GetSubtotalName() const
const o3tl::optional<OUString> & ScDPDimension::GetSubtotalName() const
{
    return mpSubtotalName;
}
@@ -2151,7 +2151,7 @@ uno::Any SAL_CALL ScDPLevel::getPropertyValue( const OUString& aPropertyName )
        if (!pDim)
            return aRet;

        const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName();
        const o3tl::optional<OUString> & pLayoutName = pDim->GetLayoutName();
        if (!pLayoutName)
            return aRet;

@@ -2511,7 +2511,7 @@ ScDPItemData ScDPMember::FillItemData() const
    return (pData ? *pData : ScDPItemData());
}

const boost::optional<OUString> & ScDPMember::GetLayoutName() const
const o3tl::optional<OUString> & ScDPMember::GetLayoutName() const
{
    return mpLayoutName;
}
diff --git a/sc/source/core/data/sheetevents.cxx b/sc/source/core/data/sheetevents.cxx
index 82853cc2..a89198c 100644
--- a/sc/source/core/data/sheetevents.cxx
+++ b/sc/source/core/data/sheetevents.cxx
@@ -19,7 +19,7 @@

#include <sheetevents.hxx>
#include <com/sun/star/script/vba/VBAEventId.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

OUString ScSheetEvents::GetEventName(ScSheetEventId nEvent)
{
@@ -88,7 +88,7 @@ ScSheetEvents& ScSheetEvents::operator=(const ScSheetEvents& rOther)
        Clear();
        if (rOther.mpScriptNames)
        {
            mpScriptNames.reset( new boost::optional<OUString>[COUNT] );
            mpScriptNames.reset( new o3tl::optional<OUString>[COUNT] );
            for (sal_Int32 nEvent=0; nEvent<COUNT; ++nEvent)
                mpScriptNames[nEvent] = rOther.mpScriptNames[nEvent];
        }
@@ -100,7 +100,7 @@ const OUString* ScSheetEvents::GetScript(ScSheetEventId nEvent) const
{
    if (mpScriptNames)
    {
        boost::optional<OUString> const & r = mpScriptNames[static_cast<int>(nEvent)];
        o3tl::optional<OUString> const & r = mpScriptNames[static_cast<int>(nEvent)];
        if (r)
            return &*r;
    }
@@ -112,7 +112,7 @@ void ScSheetEvents::SetScript(ScSheetEventId eEvent, const OUString* pNew)
    int nEvent = static_cast<int>(eEvent);
    if (!mpScriptNames)
    {
        mpScriptNames.reset( new boost::optional<OUString>[COUNT] );
        mpScriptNames.reset( new o3tl::optional<OUString>[COUNT] );
    }
    if (pNew)
        mpScriptNames[nEvent] = *pNew;
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 040456d..386f474 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -195,7 +195,7 @@ std::unique_ptr<EditTextObject> ScEditUtil::Clone( const EditTextObject& rObj, S
}

OUString ScEditUtil::GetCellFieldValue(
    const SvxFieldData& rFieldData, const ScDocument* pDoc, boost::optional<Color>* ppTextColor )
    const SvxFieldData& rFieldData, const ScDocument* pDoc, o3tl::optional<Color>* ppTextColor )
{
    OUString aRet;
    switch (rFieldData.GetClassId())
@@ -796,7 +796,7 @@ ScHeaderEditEngine::ScHeaderEditEngine( SfxItemPool* pEnginePoolP )

OUString ScHeaderEditEngine::CalcFieldValue( const SvxFieldItem& rField,
                                    sal_Int32 /* nPara */, sal_Int32 /* nPos */,
                                    boost::optional<Color>& /* rTxtColor */, boost::optional<Color>& /* rFldColor */ )
                                    o3tl::optional<Color>& /* rTxtColor */, o3tl::optional<Color>& /* rFldColor */ )
{
    const SvxFieldData* pFieldData = rField.GetField();
    if (!pFieldData)
@@ -860,7 +860,7 @@ ScFieldEditEngine::ScFieldEditEngine(

OUString ScFieldEditEngine::CalcFieldValue( const SvxFieldItem& rField,
                                    sal_Int32 /* nPara */, sal_Int32 /* nPos */,
                                    boost::optional<Color>& rTxtColor, boost::optional<Color>& /* rFldColor */ )
                                    o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& /* rFldColor */ )
{
    const SvxFieldData* pFieldData = rField.GetField();

diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 6334e0d..9f87bdf 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -922,7 +922,7 @@ void XclExpPTItem::SetPropertiesFromMember( const ScDPSaveMember& rSaveMem )
    ::set_flag( maItemInfo.mnFlags, EXC_SXVI_HIDEDETAIL, rSaveMem.HasShowDetails() && !rSaveMem.GetShowDetails() );

    // visible name
    const boost::optional<OUString> & pVisName = rSaveMem.GetLayoutName();
    const o3tl::optional<OUString> & pVisName = rSaveMem.GetLayoutName();
    if (pVisName && *pVisName != GetItemName())
        maItemInfo.SetVisName(*pVisName);
}
@@ -1005,11 +1005,11 @@ void XclExpPTField::SetPropertiesFromDim( const ScDPSaveDimension& rSaveDim )
    ::set_flag( maFieldExtInfo.mnFlags, EXC_SXVDEX_SHOWALL, rSaveDim.HasShowEmpty() && rSaveDim.GetShowEmpty() );

    // visible name
    const boost::optional<OUString> & pLayoutName = rSaveDim.GetLayoutName();
    const o3tl::optional<OUString> & pLayoutName = rSaveDim.GetLayoutName();
    if (pLayoutName && *pLayoutName != GetFieldName())
        maFieldInfo.SetVisName(*pLayoutName);

    const boost::optional<OUString> & pSubtotalName = rSaveDim.GetSubtotalName();
    const o3tl::optional<OUString> & pSubtotalName = rSaveDim.GetSubtotalName();
    if (pSubtotalName)
    {
        OUString aSubName = lcl_convertCalcSubtotalName(*pSubtotalName);
@@ -1076,7 +1076,7 @@ void XclExpPTField::SetDataPropertiesFromDim( const ScDPSaveDimension& rSaveDim 
    rDataInfo.SetApiAggFunc( eFunc );

    // visible name
    const boost::optional<OUString> & pVisName = rSaveDim.GetLayoutName();
    const o3tl::optional<OUString> & pVisName = rSaveDim.GetLayoutName();
    if (pVisName)
        rDataInfo.SetVisName(*pVisName);
    else
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx
index 28986d8..5d95ffe 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -1120,7 +1120,7 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
            long nDimIdx = rDataField.mnPos;
            assert(aCachedDims[nDimIdx]); // the loop above should have screened for NULL's.
            const ScDPSaveDimension& rDim = *rDataField.mpDim;
            boost::optional<OUString> pName = rDim.GetLayoutName();
            o3tl::optional<OUString> pName = rDim.GetLayoutName();
            // tdf#124651: despite being optional in CT_DataField according to ECMA-376 Part 1,
            // Excel (at least 2016) seems to insist on the presence of "name" attribute in
            // dataField element.
diff --git a/sc/source/filter/excel/xlpivot.cxx b/sc/source/filter/excel/xlpivot.cxx
index aa79387..c2d07ff 100644
--- a/sc/source/filter/excel/xlpivot.cxx
+++ b/sc/source/filter/excel/xlpivot.cxx
@@ -994,7 +994,7 @@ void XclPTViewEx9Info::Init( const ScDPObject& rDPObj )
    const ScDPSaveData* pData = rDPObj.GetSaveData();
    if (pData)
    {
        const boost::optional<OUString> & pGrandTotal = pData->GetGrandTotalName();
        const o3tl::optional<OUString> & pGrandTotal = pData->GetGrandTotalName();
        if (pGrandTotal)
            maGrandTotalName = *pGrandTotal;
    }
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 3da6e22..e8d0819 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -2057,7 +2057,7 @@ void ScHTMLTable::DataOn( const HtmlImportInfo& rInfo )
    {
        // read needed options from the <td> tag
        ScHTMLSize aSpanSize( 1, 1 );
        boost::optional<OUString> pValStr, pNumStr;
        o3tl::optional<OUString> pValStr, pNumStr;
        const HTMLOptions& rOptions = static_cast<HTMLParser*>(rInfo.pParser)->GetOptions();
        sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
        for (const auto& rOption : rOptions)
diff --git a/sc/source/filter/inc/eeparser.hxx b/sc/source/filter/inc/eeparser.hxx
index 681ebb5..25329a3 100644
--- a/sc/source/filter/inc/eeparser.hxx
+++ b/sc/source/filter/inc/eeparser.hxx
@@ -24,7 +24,7 @@
#include <vcl/graph.hxx>
#include <svl/itemset.hxx>
#include <editeng/editdata.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <address.hxx>
#include <memory>
#include <vector>
@@ -52,11 +52,11 @@ struct ScEEParseEntry
{
    SfxItemSet          aItemSet;
    ESelection          aSel;           // Selection in EditEngine
    boost::optional<OUString>
    o3tl::optional<OUString>
                        pValStr;        // HTML possibly SDVAL string
    boost::optional<OUString>
    o3tl::optional<OUString>
                        pNumStr;        // HTML possibly SDNUM string
    boost::optional<OUString>
    o3tl::optional<OUString>
                        pName;          // HTML possibly anchor/RangeName
    OUString            aAltText;       // HTML IMG ALT Text
    std::vector< std::unique_ptr<ScHTMLImage> > maImageList;       // graphics in this cell
diff --git a/sc/source/filter/inc/lotfntbf.hxx b/sc/source/filter/inc/lotfntbf.hxx
index d560da5..8fa9a5c 100644
--- a/sc/source/filter/inc/lotfntbf.hxx
+++ b/sc/source/filter/inc/lotfntbf.hxx
@@ -22,7 +22,7 @@

#include <editeng/fontitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

// Code in fontbuff.cxx (excel)

@@ -31,7 +31,7 @@ class LotusFontBuffer
private:
    struct ENTRY
    {
        boost::optional<OUString>           xTmpName;
        o3tl::optional<OUString>           xTmpName;
        std::unique_ptr<SvxFontItem>        pFont;
        std::unique_ptr<SvxFontHeightItem>  pHeight;
        sal_Int32                           nType = -1; // < 0 -> undefined
diff --git a/sc/source/filter/inc/xlpivot.hxx b/sc/source/filter/inc/xlpivot.hxx
index a2f3a2741b..c0df275 100644
--- a/sc/source/filter/inc/xlpivot.hxx
+++ b/sc/source/filter/inc/xlpivot.hxx
@@ -26,7 +26,7 @@
#include "xladdress.hxx"
#include <dpobject.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class XclImpStream;
class XclExpStream;
@@ -624,7 +624,7 @@ struct XclPTFieldExtInfo
    sal_uInt16          mnSortField;    /// Index to data field sorting bases on.
    sal_uInt16          mnShowField;    /// Index to data field AutoShow bases on.
    sal_uInt16          mnNumFmt;
    boost::optional<OUString> mpFieldTotalName;
    o3tl::optional<OUString> mpFieldTotalName;

    explicit            XclPTFieldExtInfo();

diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index fa88b9b..fdf042f 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -431,7 +431,7 @@ void ScXMLExportDataPilot::WriteLayoutInfo(const ScDPSaveDimension* pDim)
void ScXMLExportDataPilot::WriteSubTotals(const ScDPSaveDimension* pDim)
{
    sal_Int32 nSubTotalCount = pDim->GetSubTotalsCount();
    boost::optional<OUString> pLayoutName;
    o3tl::optional<OUString> pLayoutName;
    if (rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012)
        // Export display names only for 1.2 extended or later.
        pLayoutName = pDim->GetSubtotalName();
@@ -467,7 +467,7 @@ void ScXMLExportDataPilot::WriteMembers(const ScDPSaveDimension* pDim)
            if (rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012)
            {
                // Export display names only for ODF 1.2 extended or later.
                const boost::optional<OUString> & pLayoutName = rpMember->GetLayoutName();
                const o3tl::optional<OUString> & pLayoutName = rpMember->GetLayoutName();
                if (pLayoutName)
                    rExport.AddAttribute(XML_NAMESPACE_TABLE_EXT, XML_DISPLAY_NAME, *pLayoutName);
            }
@@ -678,7 +678,7 @@ void ScXMLExportDataPilot::WriteDimension(const ScDPSaveDimension* pDim, const S
    if (rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012)
    {
        // Export display names only for ODF 1.2 extended or later.
        const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName();
        const o3tl::optional<OUString> & pLayoutName = pDim->GetLayoutName();
        if (pLayoutName)
            rExport.AddAttribute(XML_NAMESPACE_TABLE_EXT, XML_DISPLAY_NAME, *pLayoutName);
    }
@@ -724,7 +724,7 @@ void ScXMLExportDataPilot::WriteDimensions(const ScDPSaveData* pDPSave)
    }
}

void ScXMLExportDataPilot::WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const boost::optional<OUString> & pGrandTotal)
void ScXMLExportDataPilot::WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const o3tl::optional<OUString> & pGrandTotal)
{
    rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_DISPLAY, bVisible ? XML_TRUE : XML_FALSE);
    rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_ORIENTATION, eOrient);
@@ -812,7 +812,7 @@ void ScXMLExportDataPilot::WriteDataPilots()

        // grand total elements.

        const boost::optional<OUString> & pGrandTotalName = pDPSave->GetGrandTotalName();
        const o3tl::optional<OUString> & pGrandTotalName = pDPSave->GetGrandTotalName();
        if (pGrandTotalName && rExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012)
        {
            // Use the new data-pilot-grand-total element.
diff --git a/sc/source/filter/xml/XMLExportDataPilot.hxx b/sc/source/filter/xml/XMLExportDataPilot.hxx
index 2fe6602..806e27002 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.hxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.hxx
@@ -22,7 +22,7 @@

#include <sal/config.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <rtl/ustring.hxx>
#include <global.hxx>
@@ -65,7 +65,7 @@ class ScXMLExportDataPilot
    void WriteDimension(const ScDPSaveDimension* pDim, const ScDPDimensionSaveData* pDimData);
    void WriteDimensions(const ScDPSaveData* pDPSave);

    void WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const boost::optional<OUString> & pGrandTotal);
    void WriteGrandTotal(::xmloff::token::XMLTokenEnum eOrient, bool bVisible, const o3tl::optional<OUString> & pGrandTotal);

public:
    explicit ScXMLExportDataPilot(ScXMLExport& rExport);
diff --git a/sc/source/filter/xml/XMLStylesImportHelper.cxx b/sc/source/filter/xml/XMLStylesImportHelper.cxx
index e8c2559..527dbb6 100644
--- a/sc/source/filter/xml/XMLStylesImportHelper.cxx
+++ b/sc/source/filter/xml/XMLStylesImportHelper.cxx
@@ -109,7 +109,7 @@ void ScMyStyleRanges::AddRange(const ScRange& rRange, const sal_Int16 nType)
    }
}

void ScMyStyleRanges::AddCurrencyRange(const ScRange& rRange, const boost::optional<OUString> & pCurrency)
void ScMyStyleRanges::AddCurrencyRange(const ScRange& rRange, const o3tl::optional<OUString> & pCurrency)
{
    if (!pCurrencyList)
        pCurrencyList.reset( new ScMyCurrencyStylesSet );
@@ -327,8 +327,8 @@ void ScMyStylesImportHelper::SetRowStyle(const OUString& sStyleName)
    aRowDefaultStyle = GetIterator(sStyleName);
}

void ScMyStylesImportHelper::SetAttributes(boost::optional<OUString> pStyleNameP,
    boost::optional<OUString> pCurrencyP, const sal_Int16 nCellTypeP)
void ScMyStylesImportHelper::SetAttributes(o3tl::optional<OUString> pStyleNameP,
    o3tl::optional<OUString> pCurrencyP, const sal_Int16 nCellTypeP)
{
    pStyleName = std::move(pStyleNameP);
    pCurrency = std::move(pCurrencyP);
diff --git a/sc/source/filter/xml/XMLStylesImportHelper.hxx b/sc/source/filter/xml/XMLStylesImportHelper.hxx
index 7ec3fe9..92823a4 100644
--- a/sc/source/filter/xml/XMLStylesImportHelper.hxx
+++ b/sc/source/filter/xml/XMLStylesImportHelper.hxx
@@ -29,7 +29,7 @@
#include <set>
#include <map>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class ScXMLImport;

@@ -101,7 +101,7 @@ public:
    ScMyStyleRanges();
    ~ScMyStyleRanges();
    void AddRange(const ScRange& rRange, const sal_Int16 nType);
    void AddCurrencyRange(const ScRange& rRange, const boost::optional<OUString> & pCurrency);
    void AddCurrencyRange(const ScRange& rRange, const o3tl::optional<OUString> & pCurrency);
    void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab);
    void SetStylesToRanges(const OUString* pStyleName, ScXMLImport& rImport);
};
@@ -115,13 +115,13 @@ class ScMyStylesImportHelper
    std::vector<ScMyStylesMap::iterator>  aColDefaultStyles;
    ScMyStylesMap::iterator aRowDefaultStyle;
    ScXMLImport&        rImport;
    boost::optional<OUString>
    o3tl::optional<OUString>
                        pStyleName;
    boost::optional<OUString>
    o3tl::optional<OUString>
                        pPrevStyleName;
    boost::optional<OUString>
    o3tl::optional<OUString>
                        pCurrency;
    boost::optional<OUString>
    o3tl::optional<OUString>
                        pPrevCurrency;
    ScRange             aPrevRange;
    sal_Int16           nCellType;
@@ -138,8 +138,8 @@ public:
    ~ScMyStylesImportHelper();
    void AddColumnStyle(const OUString& rStyleName, const sal_Int32 nColumn, const sal_Int32 nRepeat);
    void SetRowStyle(const OUString& rStyleName);
    void SetAttributes(boost::optional<OUString> pStyleName,
        boost::optional<OUString> pCurrency, const sal_Int16 nCellType);
    void SetAttributes(o3tl::optional<OUString> pStyleName,
        o3tl::optional<OUString> pCurrency, const sal_Int16 nCellType);
    void AddRange(const ScRange& rRange);
    void AddCell(const ScAddress& rAddress);
    void InsertCol(const sal_Int32 nCol, const sal_Int32 nTab); // a col is inserted before nCol
diff --git a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
index 21b2abd..12553aa 100644
--- a/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
+++ b/sc/source/filter/xml/XMLTableShapeImportHelper.cxx
@@ -94,7 +94,7 @@ void XMLTableShapeImportHelper::finishShape(
            sal_Int32 nEndX(-1);
            sal_Int32 nEndY(-1);
            sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
            boost::optional<OUString> xRangeList;
            o3tl::optional<OUString> xRangeList;
            SdrLayerID nLayerID = SDRLAYER_NOTFOUND;
            for( sal_Int16 i=0; i < nAttrCount; ++i )
            {
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 359f48b..59f1c9a 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -144,8 +144,8 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,

    rXMLImport.GetTables().AddColumn(bTempIsCovered);

    boost::optional<OUString> xStyleName;
    boost::optional<OUString> xCurrencySymbol;
    o3tl::optional<OUString> xStyleName;
    o3tl::optional<OUString> xCurrencySymbol;
    if ( rAttrList.is() )
    {
        for (auto &it : *rAttrList)
@@ -1034,7 +1034,7 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
}

void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos,
        const SCCOL nCurrentCol, const ::boost::optional< OUString >& pOUText )
        const SCCOL nCurrentCol, const ::o3tl::optional< OUString >& pOUText )
{
    ScDocument* pDoc = rXMLImport.GetDocument();
    bool bDoIncrement = true;
@@ -1173,7 +1173,7 @@ bool isEmptyOrNote( const ScDocument* pDoc, const ScAddress& rCurrentPos )
}

void ScXMLTableRowCellContext::AddTextAndValueCell( const ScAddress& rCellPos,
        const ::boost::optional< OUString >& pOUText, ScAddress& rCurrentPos )
        const ::o3tl::optional< OUString >& pOUText, ScAddress& rCurrentPos )
{
    ScDocument* pDoc = rXMLImport.GetDocument();
    ScMyTables& rTables = rXMLImport.GetTables();
@@ -1309,7 +1309,7 @@ OUString getOutputString( ScDocument* pDoc, const ScAddress& aCellPos )

void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
{
    ::boost::optional< OUString > pOUText;
    ::o3tl::optional< OUString > pOUText;

    ScDocument* pDoc = rXMLImport.GetDocument();
    if( nCellType == util::NumberFormat::TEXT )
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 10aeb2dd..eefeb8e 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -25,7 +25,7 @@
#include <svl/itemset.hxx>
#include <editeng/editdata.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <memory>
#include <vector>

@@ -62,10 +62,10 @@ class ScXMLTableRowCellContext : public ScXMLImportContext
    typedef std::vector<std::unique_ptr<Field> > FieldsType;
    typedef std::pair<OUString, OUString> FormulaWithNamespace;

    boost::optional<FormulaWithNamespace> maFormula; /// table:formula attribute
    boost::optional<OUString> maStringValue;         /// office:string-value attribute
    boost::optional<OUString> maContentValidationName;
    boost::optional<OUString> maFirstParagraph; /// unformatted first paragraph, for better performance.
    o3tl::optional<FormulaWithNamespace> maFormula; /// table:formula attribute
    o3tl::optional<OUString> maStringValue;         /// office:string-value attribute
    o3tl::optional<OUString> maContentValidationName;
    o3tl::optional<OUString> maFirstParagraph; /// unformatted first paragraph, for better performance.

    ScEditEngineDefaulter* mpEditEngine;
    OUStringBuffer maParagraph{32};
@@ -109,10 +109,10 @@ class ScXMLTableRowCellContext : public ScXMLImportContext

    void SetFormulaCell             ( ScFormulaCell* pFCell ) const;
    void PutTextCell                ( const ScAddress& rScCurrentPos, const SCCOL nCurrentCol,
                                      const ::boost::optional< OUString >& pOUText );
                                      const ::o3tl::optional< OUString >& pOUText );
    void PutValueCell               ( const ScAddress& rScCurrentPos );
    void AddTextAndValueCell       ( const ScAddress& rScCellPos,
                                      const ::boost::optional< OUString >& pOUText, ScAddress& rScCurrentPos );
                                      const ::o3tl::optional< OUString >& pOUText, ScAddress& rScCurrentPos );
    void AddNonFormulaCell         ( const ScAddress& rScCellPos );
    void PutFormulaCell             ( const ScAddress& rScCurrentPos );
    void AddFormulaCell             ( const ScAddress& rScCellPos );
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index 74d0b60..a9da52b 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -93,13 +93,13 @@ struct ScAccessibleShapeData
    ScAccessibleShapeData(css::uno::Reference< css::drawing::XShape > xShape_);
    ~ScAccessibleShapeData();
    mutable rtl::Reference< ::accessibility::AccessibleShape > pAccShape;
    mutable boost::optional<ScAddress> xRelationCell; // if it is NULL this shape is anchored on the table
    mutable o3tl::optional<ScAddress> xRelationCell; // if it is NULL this shape is anchored on the table
    css::uno::Reference< css::drawing::XShape > xShape;
    mutable bool            bSelected;
    bool                    bSelectable;
    // cache these to make the sorting cheaper
    boost::optional<sal_Int16> mxLayerID;
    boost::optional<sal_Int32> mxZOrder;
    o3tl::optional<sal_Int16> mxLayerID;
    o3tl::optional<sal_Int32> mxZOrder;
};

}
@@ -271,7 +271,7 @@ private:
    void FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const;
    bool FindSelectedShapesChanges(const css::uno::Reference<css::drawing::XShapes>& xShapes) const;

    boost::optional<ScAddress> GetAnchor(const uno::Reference<drawing::XShape>& xShape) const;
    o3tl::optional<ScAddress> GetAnchor(const uno::Reference<drawing::XShape>& xShape) const;
    uno::Reference<XAccessibleRelationSet> GetRelationSet(const ScAccessibleShapeData* pData) const;
    void SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const;
    void AddShape(const uno::Reference<drawing::XShape>& xShape, bool bCommitChange) const;
@@ -1119,7 +1119,7 @@ bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::X
    return bResult;
}

boost::optional<ScAddress> ScChildrenShapes::GetAnchor(const uno::Reference<drawing::XShape>& xShape) const
o3tl::optional<ScAddress> ScChildrenShapes::GetAnchor(const uno::Reference<drawing::XShape>& xShape) const
{
    if (mpViewShell)
    {
@@ -1130,12 +1130,12 @@ boost::optional<ScAddress> ScChildrenShapes::GetAnchor(const uno::Reference<draw
            if (SdrObject *pSdrObj = pShapeImp->GetSdrObject())
            {
                if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjData(pSdrObj))
                    return boost::optional<ScAddress>(pAnchor->maStart);
                    return o3tl::optional<ScAddress>(pAnchor->maStart);
            }
        }
    }

    return boost::optional<ScAddress>();
    return o3tl::optional<ScAddress>();
}

uno::Reference<XAccessibleRelationSet> ScChildrenShapes::GetRelationSet(const ScAccessibleShapeData* pData) const
@@ -1171,7 +1171,7 @@ void ScChildrenShapes::SetAnchor(const uno::Reference<drawing::XShape>& xShape, 
{
    if (pData)
    {
        boost::optional<ScAddress> xAddress = GetAnchor(xShape);
        o3tl::optional<ScAddress> xAddress = GetAnchor(xShape);
        if ((xAddress && pData->xRelationCell && (*xAddress != *(pData->xRelationCell))) ||
            (!xAddress && pData->xRelationCell) || (xAddress && !pData->xRelationCell))
        {
diff --git a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
index c4f358c..4bb3f1f 100644
--- a/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
+++ b/sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx
@@ -175,7 +175,7 @@ void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers()
    double parameter1 = parameterInteger1 / static_cast<double>(PRECISION);
    double parameter2 = parameterInteger2 / static_cast<double>(PRECISION);

    boost::optional<sal_Int8> aDecimalPlaces;
    o3tl::optional<sal_Int8> aDecimalPlaces;
    if (mxEnableRounding->get_active())
    {
        aDecimalPlaces = static_cast<sal_Int8>(mxDecimalPlaces->get_value());
@@ -250,7 +250,7 @@ void ScRandomNumberGeneratorDialog::SelectGeneratorAndGenerateNumbers()
}

template<class RNG>
void ScRandomNumberGeneratorDialog::GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, boost::optional<sal_Int8> aDecimalPlaces)
void ScRandomNumberGeneratorDialog::GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, o3tl::optional<sal_Int8> aDecimalPlaces)
{
    OUString aUndo = ScResId(STR_UNDO_DISTRIBUTION_TEMPLATE);
    OUString aDistributionName = ScResId(pDistributionStringId);
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index f9df9a2..3d03cf8 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -868,7 +868,7 @@ ScDPShowDetailDlg::ScDPShowDetailDlg(weld::Window* pParent, ScDPObject& rDPObj, 
            {
                if (pDimension)
                {
                    const boost::optional<OUString> & pLayoutName = pDimension->GetLayoutName();
                    const o3tl::optional<OUString> & pLayoutName = pDimension->GetLayoutName();
                    if (pLayoutName)
                        aName = *pLayoutName;
                }
diff --git a/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx
index f965ded..ff2fbd1 100644
--- a/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx
+++ b/sc/source/ui/inc/RandomNumberGeneratorDialog.hxx
@@ -13,7 +13,7 @@

#include <sal/config.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <address.hxx>
#include "anyrefdg.hxx"
@@ -63,7 +63,7 @@ private:

    template<class RNG>

    void GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, const boost::optional<sal_Int8> aDecimalPlaces);
    void GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, const o3tl::optional<sal_Int8> aDecimalPlaces);

    void SelectGeneratorAndGenerateNumbers();

diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index bd4ca07..a03b40e 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -104,7 +104,7 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel
    std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOHeader;
    std::unique_ptr<sdr::overlay::OverlayObjectList> mpOOShrink;

    boost::optional<tools::Rectangle> mpAutoFillRect;
    o3tl::optional<tools::Rectangle> mpAutoFillRect;

    /// LibreOfficeKit needs a persistent FmFormView for tiled rendering,
    /// otherwise the invalidations from drawinglayer do not work.
diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx
index b12592b..239e763 100644
--- a/sc/source/ui/pagedlg/scuitphfedit.cxx
+++ b/sc/source/ui/pagedlg/scuitphfedit.cxx
@@ -184,8 +184,8 @@ void ScHFEditPage::InitPreDefinedList()
{
    SvtUserOptions aUserOpt;

    boost::optional<Color> pTxtColour;
    boost::optional<Color> pFldColour;
    o3tl::optional<Color> pTxtColour;
    o3tl::optional<Color> pFldColour;

    // Get the all field values at the outset.
    OUString aPageFieldValue(m_xWndLeft->GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 14698de..a0e0f3e 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -873,7 +873,7 @@ Any SAL_CALL ScDataPilotDescriptorBase::getPropertyValue( const OUString& aPrope
            }
            else if ( aPropertyName == SC_UNO_DP_GRANDTOTAL_NAME )
            {
                const boost::optional<OUString> & pGrandTotalName = aNewData.GetGrandTotalName();
                const o3tl::optional<OUString> & pGrandTotalName = aNewData.GetGrandTotalName();
                if (pGrandTotalName)
                    aRet <<= *pGrandTotalName;      // same behavior as in ScDPSource
            }
@@ -1672,7 +1672,7 @@ OUString SAL_CALL ScDataPilotFieldObj::getName()
            aName = SC_DATALAYOUT_NAME;
        else
        {
            const boost::optional<OUString> & pLayoutName = pDim->GetLayoutName();
            const o3tl::optional<OUString> & pLayoutName = pDim->GetLayoutName();
            if (pLayoutName)
                aName = *pLayoutName;
            else
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
index 331b38d..6de682a 100644
--- a/sc/source/ui/unoobj/fielduno.cxx
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -177,7 +177,7 @@ public:
    explicit ScUnoEditEngine(ScEditEngineDefaulter* pSource);

    virtual OUString  CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
                                   boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor ) override;
                                   o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor ) override;

    sal_uInt16 CountFields();
    SvxFieldData* FindByIndex(sal_uInt16 nIndex);
@@ -203,7 +203,7 @@ ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter* pSource)
}

OUString ScUnoEditEngine::CalcFieldValue( const SvxFieldItem& rField,
            sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rTxtColor, boost::optional<Color>& rFldColor )
            sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rTxtColor, o3tl::optional<Color>& rFldColor )
{
    OUString aRet(EditEngine::CalcFieldValue( rField, nPara, nPos, rTxtColor, rFldColor ));
    if (eMode != SC_UNO_COLLECT_NONE)
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 07a61bf..0a76a77 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -1541,7 +1541,7 @@ void ScDBFunc::DataPilotInput( const ScAddress& rPos, const OUString& rString )
                            if (pDim->GetSubTotalFunc(0) != ScGeneralFunction::AUTO)
                                break;

                            const boost::optional<OUString> & pLayoutName = pMem->GetLayoutName();
                            const o3tl::optional<OUString> & pLayoutName = pMem->GetLayoutName();
                            OUString aMemberName;
                            if (pLayoutName)
                                aMemberName = *pLayoutName;
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index e14647b..9af78a0 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -774,8 +774,8 @@ static bool lcl_EqualBack( const RowInfo& rFirst, const RowInfo& rOther,

    for ( nX=nX1; nX<=nX2; nX++ )
    {
        boost::optional<Color> const & pCol1 = rFirst.pCellInfo[nX+1].mxColorScale;
        boost::optional<Color> const & pCol2 = rOther.pCellInfo[nX+1].mxColorScale;
        o3tl::optional<Color> const & pCol1 = rFirst.pCellInfo[nX+1].mxColorScale;
        o3tl::optional<Color> const & pCol2 = rOther.pCellInfo[nX+1].mxColorScale;
        if( (pCol1 && !pCol2) || (!pCol1 && pCol2) )
            return false;

@@ -909,7 +909,7 @@ void drawIconSets(vcl::RenderContext& rRenderContext, const ScIconSetInfo* pOldI
    rRenderContext.DrawBitmapEx( Point( rRect.Left() + 2 * nOneX, rRect.Top() + 2 * nOneY), Size(aOrigSize, aOrigSize), rIcon );
}

void drawCells(vcl::RenderContext& rRenderContext, boost::optional<Color> const & pColor, const SvxBrushItem* pBackground, boost::optional<Color>& pOldColor, const SvxBrushItem*& pOldBackground,
void drawCells(vcl::RenderContext& rRenderContext, o3tl::optional<Color> const & pColor, const SvxBrushItem* pBackground, o3tl::optional<Color>& pOldColor, const SvxBrushItem*& pOldBackground,
        tools::Rectangle& rRect, long nPosX, long nLayoutSign, long nOneX, long nOneY, const ScDataBarInfo* pDataBarInfo, const ScDataBarInfo*& pOldDataBarInfo,
        const ScIconSetInfo* pIconSetInfo, const ScIconSetInfo*& pOldIconSetInfo,
        sc::IconSetBitmapMap & rIconSetBitmapMap)
@@ -1059,7 +1059,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext)

                const SvxBrushItem* pOldBackground = nullptr;
                const SvxBrushItem* pBackground = nullptr;
                boost::optional<Color> pOldColor;
                o3tl::optional<Color> pOldColor;
                const ScDataBarInfo* pOldDataBarInfo = nullptr;
                const ScIconSetInfo* pOldIconSetInfo = nullptr;
                SCCOL nMergedCols = 1;
@@ -1104,7 +1104,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext)
                        pBackground = lcl_FindBackground( mpDoc, nX, nY, nTab );
                    }

                    boost::optional<Color> const & pColor = pInfo->mxColorScale;
                    o3tl::optional<Color> const & pColor = pInfo->mxColorScale;
                    const ScDataBarInfo* pDataBarInfo = pInfo->pDataBar.get();
                    const ScIconSetInfo* pIconSetInfo = pInfo->pIconSet.get();

@@ -1136,7 +1136,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext)
                if (bWorksInPixels)
                    nPosXLogic = rRenderContext.PixelToLogic(Point(nPosX, 0)).X();

                drawCells(rRenderContext, boost::optional<Color>(), nullptr, pOldColor, pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, nullptr, pOldDataBarInfo, nullptr, pOldIconSetInfo, mpDoc->GetIconSetBitmapMap());
                drawCells(rRenderContext, o3tl::optional<Color>(), nullptr, pOldColor, pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, nullptr, pOldDataBarInfo, nullptr, pOldIconSetInfo, mpDoc->GetIconSetBitmapMap());

                nArrY += nSkip;
            }
@@ -1650,7 +1650,7 @@ void ScOutputData::DrawRotatedFrame(vcl::RenderContext& rRenderContext)
                        else
                        {
                            tools::Polygon aPoly(4, aPoints);
                            boost::optional<Color> const & pColor = pInfo->mxColorScale;
                            o3tl::optional<Color> const & pColor = pInfo->mxColorScale;

                            // for DrawPolygon, without Pen one pixel is left out
                            // to the right and below...
diff --git a/sd/inc/pch/precompiled_sd.hxx b/sd/inc/pch/precompiled_sd.hxx
index cea2898..475d59d 100644
--- a/sd/inc/pch/precompiled_sd.hxx
+++ b/sd/inc/pch/precompiled_sd.hxx
@@ -39,8 +39,8 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <boost/optional/optional.hpp>
#include <o3tl/optional.hxx>
#include <o3tl/optional.hxx>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
diff --git a/sd/inc/pch/precompiled_sdui.hxx b/sd/inc/pch/precompiled_sdui.hxx
index 0922819..bfd2e4b 100644
--- a/sd/inc/pch/precompiled_sdui.hxx
+++ b/sd/inc/pch/precompiled_sdui.hxx
@@ -50,7 +50,7 @@
#include <typeinfo>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index b641545..cd1d620 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -87,7 +87,7 @@
#include <comphelper/string.hxx>
#include <oox/ole/olehelper.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <cassert>
#include <memory>
@@ -583,7 +583,7 @@ bool ImplSdPPTImport::Import()
                    pPage->SetAutoLayout( AUTOLAYOUT_NOTES, true );
                if ( nMasterNum )
                {
                    boost::optional< sal_Int16 > oStartNumbering;
                    o3tl::optional< sal_Int16 > oStartNumbering;
                    SfxStyleSheet* pSheet;
                    if ( nMasterNum == 1 )
                    {
diff --git a/sd/source/ui/app/sdmod2.cxx b/sd/source/ui/app/sdmod2.cxx
index 1a09eb0..5bc72ad 100644
--- a/sd/source/ui/app/sdmod2.cxx
+++ b/sd/source/ui/app/sdmod2.cxx
@@ -335,7 +335,7 @@ IMPL_LINK(SdModule, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
    }
    else if ( dynamic_cast< const SdrMeasureField* >(pField))
    {
        pInfo->SetFieldColor(boost::optional<Color>()); // clear the field color
        pInfo->SetFieldColor(o3tl::optional<Color>()); // clear the field color
    }
    else if ((pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pField)) != nullptr)
    {
diff --git a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
index 2337802..d54b09a 100644
--- a/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSelectionFunction.cxx
@@ -51,7 +51,7 @@
#include <o3tl/deleter.hxx>
#include <sfx2/dispatch.hxx>
#include <vcl/ptrstyle.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <sdmod.hxx>

namespace {
@@ -198,7 +198,7 @@ protected:
    virtual bool ProcessDragEvent (SelectionFunction::EventDescriptor& rDescriptor) override;

private:
    ::boost::optional<Point> maButtonDownLocation;
    ::o3tl::optional<Point> maButtonDownLocation;

    /** Select all pages between and including the selection anchor and the
        specified page.
@@ -1183,7 +1183,7 @@ void NormalModeHandler::RangeSelect (const model::SharedPageDescriptor& rpDescri

void NormalModeHandler::ResetButtonDownLocation()
{
    maButtonDownLocation = ::boost::optional<Point>();
    maButtonDownLocation = ::o3tl::optional<Point>();
}

//===== MultiSelectionModeHandler =============================================
diff --git a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx
index ff16fb0..b495de5 100644
--- a/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsVisibleAreaManager.cxx
@@ -107,7 +107,7 @@ void VisibleAreaManager::MakeVisible()
        return;
    const Point aCurrentTopLeft (pWindow->PixelToLogic(Point(0,0)));

    const ::boost::optional<Point> aNewVisibleTopLeft (GetRequestedTopLeft());
    const ::o3tl::optional<Point> aNewVisibleTopLeft (GetRequestedTopLeft());
    maVisibleRequests.clear();
    if ( ! aNewVisibleTopLeft)
        return;
@@ -121,11 +121,11 @@ void VisibleAreaManager::MakeVisible()
    aAnimation(1.0);
}

::boost::optional<Point> VisibleAreaManager::GetRequestedTopLeft() const
::o3tl::optional<Point> VisibleAreaManager::GetRequestedTopLeft() const
{
    sd::Window *pWindow (mrSlideSorter.GetContentWindow().get());
    if ( ! pWindow)
        return ::boost::optional<Point>();
        return ::o3tl::optional<Point>();

    // Get the currently visible area and the model area.
    const ::tools::Rectangle aVisibleArea (pWindow->PixelToLogic(
@@ -166,9 +166,9 @@ void VisibleAreaManager::MakeVisible()

    const Point aRequestedTopLeft (nVisibleLeft, nVisibleTop);
    if (aRequestedTopLeft == aVisibleArea.TopLeft())
        return ::boost::optional<Point>();
        return ::o3tl::optional<Point>();
    else
        return ::boost::optional<Point>(aRequestedTopLeft);
        return ::o3tl::optional<Point>(aRequestedTopLeft);
}

//===== VisibleAreaManager::TemporaryDisabler =================================
diff --git a/sd/source/ui/slidesorter/inc/controller/SlsVisibleAreaManager.hxx b/sd/source/ui/slidesorter/inc/controller/SlsVisibleAreaManager.hxx
index acd74e2..8ac72f7 100644
--- a/sd/source/ui/slidesorter/inc/controller/SlsVisibleAreaManager.hxx
+++ b/sd/source/ui/slidesorter/inc/controller/SlsVisibleAreaManager.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_SD_SOURCE_UI_SLIDESORTER_INC_CONTROLLER_SLSVISIBLEAREAMANAGER_HXX

#include <model/SlsSharedPageDescriptor.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <tools/gen.hxx>
#include <vector>

@@ -81,7 +81,7 @@ private:
    int  mnDisableCount;

    void MakeVisible();
    ::boost::optional<Point> GetRequestedTopLeft() const;
    ::o3tl::optional<Point> GetRequestedTopLeft() const;
};

} } } // end of namespace ::sd::slidesorter::view
diff --git a/sfx2/inc/pch/precompiled_sfx.hxx b/sfx2/inc/pch/precompiled_sfx.hxx
index b4e1587..1e86678 100644
--- a/sfx2/inc/pch/precompiled_sfx.hxx
+++ b/sfx2/inc/pch/precompiled_sfx.hxx
@@ -45,7 +45,7 @@
#include <utility>
#include <vector>
#include <boost/logic/tribool.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/json_parser.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 945d24a..f5689b3 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -1174,7 +1174,7 @@ void BookmarksBox_Impl::dispose()
    for ( sal_Int32 i = 0; i < nCount; ++i )
    {
        OUString* pURL = static_cast<OUString*>(GetEntryData(i));
        aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, "", GetEntry(i), boost::none);
        aHistOpt.AppendItem(eHELPBOOKMARKS, *pURL, "", GetEntry(i), o3tl::nullopt);
        delete pURL;
    }
    ListBox::dispose();
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index 2284c8b..8ec36aa 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -117,7 +117,7 @@ void SfxPickListImpl::AddDocumentToPickList( const SfxObjectShell* pDocSh )
    if ( pFilter )
        aFilter = pFilter->GetFilterName();

    boost::optional<OUString> aThumbnail;
    o3tl::optional<OUString> aThumbnail;

    // generate the thumbnail
    //fdo#74834: only generate thumbnail for history if the corresponding option is not disabled in the configuration
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index b8f0b04..b9d072d 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -79,7 +79,7 @@
#include <sfx2/docfile.hxx>
#include <sax/tools/converter.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <utility>
#include <vector>
@@ -454,7 +454,7 @@ OUString getNameSpace(const char* i_qname) throw ()

bool
textToDateOrDateTime(css::util::Date & io_rd, css::util::DateTime & io_rdt,
        bool & o_rIsDateTime, boost::optional<sal_Int16> & o_rTimeZone,
        bool & o_rIsDateTime, o3tl::optional<sal_Int16> & o_rTimeZone,
        const OUString& i_text) throw ()
{
    if (::sax::Converter::parseDateOrDateTime(
@@ -1188,7 +1188,7 @@ void SfxDocumentMetaData::init(
            bool isDateTime;
            css::util::Date d;
            css::util::DateTime dt;
            boost::optional<sal_Int16> nTimeZone;
            o3tl::optional<sal_Int16> nTimeZone;
            if (textToDateOrDateTime(d, dt, isDateTime, nTimeZone, text)) {
                if (isDateTime) {
                    if (nTimeZone) {
diff --git a/sfx2/source/view/impviewframe.hxx b/sfx2/source/view/impviewframe.hxx
index 60c8c5b..568c279 100644
--- a/sfx2/source/view/impviewframe.hxx
+++ b/sfx2/source/view/impviewframe.hxx
@@ -26,7 +26,7 @@
#include <tools/svborder.hxx>
#include <vcl/window.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

struct SfxViewFrame_Impl
{
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 6c0ee87..5e81262 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -94,7 +94,7 @@
#include <framework/framelistanalyzer.hxx>
#include <shellimpl.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <unotools/configmgr.hxx>

@@ -468,7 +468,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
                bool bOK = false;
                bool bRetryIgnoringLock = false;
                bool bOpenTemplate = false;
                boost::optional<bool> aOrigROVal;
                o3tl::optional<bool> aOrigROVal;
                if (!pVersionItem)
                {
                    auto pRO = pMed->GetItemSet()->GetItem<SfxBoolItem>(SID_DOC_READONLY, false);
@@ -2354,7 +2354,7 @@ void SfxViewFrame::ExecView_Impl
static bool impl_maxOpenDocCountReached()
{
    css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
    boost::optional<sal_Int32> x(officecfg::Office::Common::Misc::MaxOpenDocuments::get(xContext));
    o3tl::optional<sal_Int32> x(officecfg::Office::Common::Misc::MaxOpenDocuments::get(xContext));
    // NIL means: count of allowed documents = infinite !
    if (!x)
        return false;
diff --git a/slideshow/inc/pch/precompiled_slideshow.hxx b/slideshow/inc/pch/precompiled_slideshow.hxx
index 7bd2a3b..c7708cb 100644
--- a/slideshow/inc/pch/precompiled_slideshow.hxx
+++ b/slideshow/inc/pch/precompiled_slideshow.hxx
@@ -49,7 +49,7 @@
#include <unordered_set>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/slideshow/source/engine/activities/activitiesfactory.cxx b/slideshow/source/engine/activities/activitiesfactory.cxx
index e2cc998..9f24302 100644
--- a/slideshow/source/engine/activities/activitiesfactory.cxx
+++ b/slideshow/source/engine/activities/activitiesfactory.cxx
@@ -34,7 +34,7 @@
#include "continuousactivitybase.hxx"
#include "continuouskeytimeactivitybase.hxx"

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <memory>
#include <cmath>
@@ -102,7 +102,7 @@ class FromToByActivity : public BaseType
{
public:
    typedef typename AnimationType::ValueType           ValueType;
    typedef boost::optional<ValueType>                  OptionalValueType;
    typedef o3tl::optional<ValueType>                  OptionalValueType;

private:
    // some compilers don't inline whose definition they haven't
@@ -390,7 +390,7 @@ AnimationActivitySharedPtr createFromToByActivity(
    const ::basegfx::B2DVector&                              rSlideBounds )
{
    typedef typename AnimationType::ValueType           ValueType;
    typedef boost::optional<ValueType>                  OptionalValueType;
    typedef o3tl::optional<ValueType>                  OptionalValueType;

    OptionalValueType aFrom;
    OptionalValueType aTo;
diff --git a/slideshow/source/engine/activities/activitybase.hxx b/slideshow/source/engine/activities/activitybase.hxx
index 990e65c..8fdc6be 100644
--- a/slideshow/source/engine/activities/activitybase.hxx
+++ b/slideshow/source/engine/activities/activitybase.hxx
@@ -126,7 +126,7 @@ private:
    AnimatableShapeSharedPtr        mpShape; // only to pass on to animation
    ShapeAttributeLayerSharedPtr    mpAttributeLayer; // only to pass on to anim

    ::boost::optional<double> const maRepeats;
    ::o3tl::optional<double> const maRepeats;
    const double                    mnAccelerationFraction;
    const double                    mnDecelerationFraction;

diff --git a/slideshow/source/engine/activities/activityparameters.hxx b/slideshow/source/engine/activities/activityparameters.hxx
index 0644ccf..d915230 100644
--- a/slideshow/source/engine/activities/activityparameters.hxx
+++ b/slideshow/source/engine/activities/activityparameters.hxx
@@ -25,7 +25,7 @@
#include <expressionnode.hxx>
#include <wakeupevent.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <vector>

namespace slideshow {
@@ -80,7 +80,7 @@ struct ActivityParameters
        EventQueue&                                 rEventQueue,
        ActivitiesQueue&                            rActivitiesQueue,
        double                                      nMinDuration,
        ::boost::optional<double> const&            rRepeats,
        ::o3tl::optional<double> const&            rRepeats,
        double                                      nAccelerationFraction,
        double                                      nDecelerationFraction,
        sal_uInt32                                  nMinNumberOfFrames,
@@ -117,7 +117,7 @@ struct ActivityParameters

    /// Total duration of activity (including all repeats)
    const double                                mnMinDuration;
    ::boost::optional<double> const&            mrRepeats;
    ::o3tl::optional<double> const&            mrRepeats;
    const double                                mnAccelerationFraction;
    const double                                mnDecelerationFraction;

diff --git a/slideshow/source/engine/animationnodes/animationbasenode.cxx b/slideshow/source/engine/animationnodes/animationbasenode.cxx
index a302b171..1aa7bbc 100644
--- a/slideshow/source/engine/animationnodes/animationbasenode.cxx
+++ b/slideshow/source/engine/animationnodes/animationbasenode.cxx
@@ -33,7 +33,7 @@
#include <delayevent.hxx>
#include <framerate.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <algorithm>

using namespace com::sun::star;
@@ -401,7 +401,7 @@ AnimationBaseNode::fillCommonParameters() const

    const bool bAutoReverse( mxAnimateNode->getAutoReverse() );

    boost::optional<double> aRepeats;
    o3tl::optional<double> aRepeats;
    double nRepeats = 0;
    if( mxAnimateNode->getRepeatCount() >>= nRepeats ) {
        aRepeats = nRepeats;
diff --git a/slideshow/source/engine/shapes/drawshape.hxx b/slideshow/source/engine/shapes/drawshape.hxx
index e014f0c..e76fe9c 100644
--- a/slideshow/source/engine/shapes/drawshape.hxx
+++ b/slideshow/source/engine/shapes/drawshape.hxx
@@ -29,7 +29,7 @@
#include "viewshape.hxx"
#include <hyperlinkarea.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <set>
#include <vector>

@@ -292,7 +292,7 @@ namespace slideshow
            mutable int                                                             mnCurrMtfLoadFlags;

            /// Contains the current shape bounds, in unit rect space
            mutable ::boost::optional<basegfx::B2DRectangle>                        maCurrentShapeUnitBounds;
            mutable ::o3tl::optional<basegfx::B2DRectangle>                        maCurrentShapeUnitBounds;

            // The attributes of this Shape
            const double                                                            mnPriority;
diff --git a/slideshow/source/engine/shapes/viewshape.cxx b/slideshow/source/engine/shapes/viewshape.cxx
index b898040..c3b676d 100644
--- a/slideshow/source/engine/shapes/viewshape.cxx
+++ b/slideshow/source/engine/shapes/viewshape.cxx
@@ -551,7 +551,7 @@ namespace slideshow
            // shape needs repaint - setup all that's needed


            boost::optional<basegfx::B2DPolyPolygon> aClip;
            o3tl::optional<basegfx::B2DPolyPolygon> aClip;

            if( pAttr )
            {
diff --git a/slideshow/source/engine/slideshowimpl.cxx b/slideshow/source/engine/slideshowimpl.cxx
index f81e9e9..3786571 100644
--- a/slideshow/source/engine/slideshowimpl.cxx
+++ b/slideshow/source/engine/slideshowimpl.cxx
@@ -424,13 +424,13 @@ private:
    //map of vector of Polygons, containing polygons drawn on each slide.
    PolygonMap                              maPolygons;

    boost::optional<RGBColor>               maUserPaintColor;
    o3tl::optional<RGBColor>               maUserPaintColor;

    double                                  maUserPaintStrokeWidth;

    //changed for the eraser project
    boost::optional<bool>           maEraseAllInk;
    boost::optional<sal_Int32>          maEraseInk;
    o3tl::optional<bool>           maEraseAllInk;
    o3tl::optional<sal_Int32>          maEraseInk;
    //end changed

    std::shared_ptr<canvas::tools::ElapsedTime> mpPresTimer;
@@ -864,7 +864,7 @@ ActivitySharedPtr SlideShowImpl::createSlideTransition(
                nTransitionDuration,
                nMinFrames,
                false,
                boost::optional<double>(1.0),
                o3tl::optional<double>(1.0),
                0.0,
                0.0,
                ShapeSharedPtr(),
diff --git a/slideshow/source/engine/transitions/combtransition.cxx b/slideshow/source/engine/transitions/combtransition.cxx
index 65c32b6..d6c17e5 100644
--- a/slideshow/source/engine/transitions/combtransition.cxx
+++ b/slideshow/source/engine/transitions/combtransition.cxx
@@ -68,7 +68,7 @@ basegfx::B2DPolyPolygon createClipPolygon(
}

CombTransition::CombTransition(
    boost::optional<SlideSharedPtr> const & leavingSlide,
    o3tl::optional<SlideSharedPtr> const & leavingSlide,
    const SlideSharedPtr&                   pEnteringSlide,
    const SoundPlayerSharedPtr&             pSoundPlayer,
    const UnoViewContainer&                 rViewContainer,
diff --git a/slideshow/source/engine/transitions/combtransition.hxx b/slideshow/source/engine/transitions/combtransition.hxx
index 1f1509a..c0d2f46 100644
--- a/slideshow/source/engine/transitions/combtransition.hxx
+++ b/slideshow/source/engine/transitions/combtransition.hxx
@@ -39,7 +39,7 @@ public:
        @param nNumStripes
        Number of comb-like stripes to show in this effect
    */
    CombTransition( ::boost::optional<SlideSharedPtr> const & leavingSlide,
    CombTransition( ::o3tl::optional<SlideSharedPtr> const & leavingSlide,
                    const SlideSharedPtr&                     pEnteringSlide,
                    const SoundPlayerSharedPtr&               pSoundPlayer,
                    const UnoViewContainer&                   rViewContainer,
diff --git a/slideshow/source/engine/transitions/slidechangebase.cxx b/slideshow/source/engine/transitions/slidechangebase.cxx
index d972109..3fbad5b 100644
--- a/slideshow/source/engine/transitions/slidechangebase.cxx
+++ b/slideshow/source/engine/transitions/slidechangebase.cxx
@@ -37,7 +37,7 @@ using namespace com::sun::star;
namespace slideshow {
namespace internal {

SlideChangeBase::SlideChangeBase( boost::optional<SlideSharedPtr> const & leavingSlide,
SlideChangeBase::SlideChangeBase( o3tl::optional<SlideSharedPtr> const & leavingSlide,
                                  const SlideSharedPtr&                   pEnteringSlide,
                                  const SoundPlayerSharedPtr&             pSoundPlayer,
                                  const UnoViewContainer&                 rViewContainer,
@@ -76,13 +76,13 @@ SlideBitmapSharedPtr SlideChangeBase::getEnteringBitmap( const ViewEntry& rViewE
{
    if( !rViewEntry.mpEnteringBitmap )
        rViewEntry.mpEnteringBitmap = createBitmap( rViewEntry.mpView,
                                                    boost::optional<SlideSharedPtr>(mpEnteringSlide) );
                                                    o3tl::optional<SlideSharedPtr>(mpEnteringSlide) );

    return rViewEntry.mpEnteringBitmap;
}

SlideBitmapSharedPtr SlideChangeBase::createBitmap( const UnoViewSharedPtr&                rView,
                                                    const boost::optional<SlideSharedPtr>& rSlide ) const
                                                    const o3tl::optional<SlideSharedPtr>& rSlide ) const
{
    SlideBitmapSharedPtr pRet;
    if( !rSlide )
diff --git a/slideshow/source/engine/transitions/slidechangebase.hxx b/slideshow/source/engine/transitions/slidechangebase.hxx
index 0cb20b1a..443c8ed 100644
--- a/slideshow/source/engine/transitions/slidechangebase.hxx
+++ b/slideshow/source/engine/transitions/slidechangebase.hxx
@@ -28,7 +28,7 @@
#include <soundplayer.hxx>

#include <memory>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace cppcanvas
{
@@ -73,7 +73,7 @@ protected:
        entering slides.
    */
    SlideChangeBase(
        ::boost::optional<SlideSharedPtr> const & leavingSlide,
        ::o3tl::optional<SlideSharedPtr> const & leavingSlide,
        const SlideSharedPtr&                     pEnteringSlide,
        const SoundPlayerSharedPtr&               pSoundPlayer,
        const UnoViewContainer&                   rViewContainer,
@@ -114,7 +114,7 @@ protected:
    SlideBitmapSharedPtr getEnteringBitmap( const ViewEntry& rViewEntry ) const;

    SlideBitmapSharedPtr createBitmap( const UnoViewSharedPtr&                pView,
                                       const boost::optional<SlideSharedPtr>& rSlide_ ) const;
                                       const o3tl::optional<SlideSharedPtr>& rSlide_ ) const;

    ::basegfx::B2ISize getEnteringSlideSizePixel( const UnoViewSharedPtr& pView ) const;

@@ -184,7 +184,7 @@ private:
    EventMultiplexer&                   mrEventMultiplexer;
    ScreenUpdater&                      mrScreenUpdater;

    ::boost::optional<SlideSharedPtr>   maLeavingSlide;
    ::o3tl::optional<SlideSharedPtr>   maLeavingSlide;
    SlideSharedPtr                      mpEnteringSlide;

    ViewsVecT                           maViewData;
diff --git a/slideshow/source/engine/transitions/slidetransitionfactory.cxx b/slideshow/source/engine/transitions/slidetransitionfactory.cxx
index 49d440aa..34ee72e 100644
--- a/slideshow/source/engine/transitions/slidetransitionfactory.cxx
+++ b/slideshow/source/engine/transitions/slidetransitionfactory.cxx
@@ -118,7 +118,7 @@ public:
    */
    PluginSlideChange( sal_Int16                                nTransitionType,
                       sal_Int16                                nTransitionSubType,
                       boost::optional<SlideSharedPtr> const&   leavingSlide_,
                       o3tl::optional<SlideSharedPtr> const&   leavingSlide_,
                       const SlideSharedPtr&                    pEnteringSlide,
                       const UnoViewContainer&                  rViewContainer,
                       ScreenUpdater&                           rScreenUpdater,
@@ -280,7 +280,7 @@ public:
        SlideChangeBase(
            // leaving bitmap is empty, we're leveraging the fact that the
            // old slide is still displayed in the background:
            boost::optional<SlideSharedPtr>(),
            o3tl::optional<SlideSharedPtr>(),
            pEnteringSlide,
            pSoundPlayer,
            rViewContainer,
@@ -341,9 +341,9 @@ public:
        entering slides, which applies a fade effect.
    */
    FadingSlideChange(
        boost::optional<SlideSharedPtr> const & leavingSlide,
        o3tl::optional<SlideSharedPtr> const & leavingSlide,
        const SlideSharedPtr&                   pEnteringSlide,
        boost::optional<RGBColor> const&        rFadeColor,
        o3tl::optional<RGBColor> const&        rFadeColor,
        const SoundPlayerSharedPtr&             pSoundPlayer,
        const UnoViewContainer&                 rViewContainer,
        ScreenUpdater&                          rScreenUpdater,
@@ -374,7 +374,7 @@ public:
        double                                     t ) override;

private:
    const boost::optional< RGBColor >               maFadeColor;
    const o3tl::optional< RGBColor >               maFadeColor;
};

void FadingSlideChange::prepareForRun(
@@ -439,7 +439,7 @@ public:
        entering slides, which applies a cut effect.
    */
    CutSlideChange(
        boost::optional<SlideSharedPtr> const & leavingSlide,
        o3tl::optional<SlideSharedPtr> const & leavingSlide,
        const SlideSharedPtr&                   pEnteringSlide,
        const RGBColor&                          rFadeColor,
        const SoundPlayerSharedPtr&             pSoundPlayer,
@@ -543,7 +543,7 @@ public:
        final slide position. The vector must have unit length.
    */
    MovingSlideChange(
        const boost::optional<SlideSharedPtr>& leavingSlide,
        const o3tl::optional<SlideSharedPtr>& leavingSlide,
        const SlideSharedPtr&                  pEnteringSlide,
        const SoundPlayerSharedPtr&            pSoundPlayer,
        const UnoViewContainer&                rViewContainer,
@@ -661,7 +661,7 @@ void MovingSlideChange::performOut(


NumberAnimationSharedPtr createPushWipeTransition(
    boost::optional<SlideSharedPtr> const &         leavingSlide_,
    o3tl::optional<SlideSharedPtr> const &         leavingSlide_,
    const SlideSharedPtr&                           pEnteringSlide,
    const UnoViewContainer&                         rViewContainer,
    ScreenUpdater&                                  rScreenUpdater,
@@ -671,7 +671,7 @@ NumberAnimationSharedPtr createPushWipeTransition(
    bool                                            /*bTransitionDirection*/,
    const SoundPlayerSharedPtr&                     pSoundPlayer )
{
    boost::optional<SlideSharedPtr> leavingSlide; // no bitmap
    o3tl::optional<SlideSharedPtr> leavingSlide; // no bitmap
    if (leavingSlide_ && *leavingSlide_ != nullptr)
    {
        // opt: only page, if we've an
@@ -764,7 +764,7 @@ NumberAnimationSharedPtr createPushWipeTransition(
}

NumberAnimationSharedPtr createSlideWipeTransition(
    boost::optional<SlideSharedPtr> const &         leavingSlide,
    o3tl::optional<SlideSharedPtr> const &         leavingSlide,
    const SlideSharedPtr&                           pEnteringSlide,
    const UnoViewContainer&                         rViewContainer,
    ScreenUpdater&                                  rScreenUpdater,
@@ -827,7 +827,7 @@ NumberAnimationSharedPtr createSlideWipeTransition(

        return NumberAnimationSharedPtr(
            new MovingSlideChange(
                boost::optional<SlideSharedPtr>() /* no slide */,
                o3tl::optional<SlideSharedPtr>() /* no slide */,
                pEnteringSlide,
                pSoundPlayer,
                rViewContainer,
@@ -858,7 +858,7 @@ NumberAnimationSharedPtr createSlideWipeTransition(
NumberAnimationSharedPtr createPluginTransition(
    sal_Int16                                nTransitionType,
    sal_Int16                                nTransitionSubType,
    boost::optional<SlideSharedPtr> const&   pLeavingSlide,
    o3tl::optional<SlideSharedPtr> const&   pLeavingSlide,
    const SlideSharedPtr&                    pEnteringSlide,
    const UnoViewContainer&                  rViewContainer,
    ScreenUpdater&                           rScreenUpdater,
@@ -926,7 +926,7 @@ NumberAnimationSharedPtr TransitionFactory::createSlideTransition(
            createPluginTransition(
                nTransitionType,
                nTransitionSubType,
                boost::make_optional(pLeavingSlide),
                o3tl::make_optional(pLeavingSlide),
                pEnteringSlide,
                rViewContainer,
                rScreenUpdater,
@@ -1021,7 +1021,7 @@ NumberAnimationSharedPtr TransitionFactory::createSlideTransition(
                    case animations::TransitionType::PUSHWIPE:
                    {
                        return createPushWipeTransition(
                            boost::make_optional(pLeavingSlide),
                            o3tl::make_optional(pLeavingSlide),
                            pEnteringSlide,
                            rViewContainer,
                            rScreenUpdater,
@@ -1035,7 +1035,7 @@ NumberAnimationSharedPtr TransitionFactory::createSlideTransition(
                    case animations::TransitionType::SLIDEWIPE:
                    {
                        return createSlideWipeTransition(
                            boost::make_optional(pLeavingSlide),
                            o3tl::make_optional(pLeavingSlide),
                            pEnteringSlide,
                            rViewContainer,
                            rScreenUpdater,
@@ -1050,8 +1050,8 @@ NumberAnimationSharedPtr TransitionFactory::createSlideTransition(
                    case animations::TransitionType::FADE:
                    {
                        // black page:
                        boost::optional<SlideSharedPtr> leavingSlide;
                        boost::optional<RGBColor> aFadeColor;
                        o3tl::optional<SlideSharedPtr> leavingSlide;
                        o3tl::optional<RGBColor> aFadeColor;

                        switch( nTransitionSubType )
                        {
diff --git a/slideshow/source/inc/activitiesfactory.hxx b/slideshow/source/inc/activitiesfactory.hxx
index ccf641d..1734fc1 100644
--- a/slideshow/source/inc/activitiesfactory.hxx
+++ b/slideshow/source/inc/activitiesfactory.hxx
@@ -36,7 +36,7 @@
#include "boolanimation.hxx"
#include "pairanimation.hxx"

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

/* Definition of ActivitiesFactory class */

@@ -55,7 +55,7 @@ namespace ActivitiesFactory
            double                                nMinDuration,
            sal_uInt32                            nMinNumberOfFrames,
            bool                                  bAutoReverse,
            ::boost::optional<double> const&      aRepeats,
            ::o3tl::optional<double> const&      aRepeats,
            double                                nAcceleration,
            double                                nDeceleration,
            const ShapeSharedPtr&                 rShape,
@@ -110,7 +110,7 @@ namespace ActivitiesFactory
            unspecified, the activity will repeat
            indefinitely.
        */
        ::boost::optional<double> const                 maRepeats;
        ::o3tl::optional<double> const                 maRepeats;

        /// Fraction of simple time to accelerate animation
        double const                                    mnAcceleration;
diff --git a/slideshow/source/inc/animatedsprite.hxx b/slideshow/source/inc/animatedsprite.hxx
index 3c215ed..db38190 100644
--- a/slideshow/source/inc/animatedsprite.hxx
+++ b/slideshow/source/inc/animatedsprite.hxx
@@ -29,7 +29,7 @@

#include "viewlayer.hxx"

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <memory>


@@ -148,8 +148,8 @@ namespace slideshow

            double const                                                mnSpritePrio;
            double                                                      mnAlpha;
            ::boost::optional< ::basegfx::B2DPoint >                    maPosPixel;
            ::boost::optional< ::basegfx::B2DPolyPolygon >              maClip;
            ::o3tl::optional< ::basegfx::B2DPoint >                    maPosPixel;
            ::o3tl::optional< ::basegfx::B2DPolyPolygon >              maClip;

            bool                                                        mbSpriteVisible;
        };
diff --git a/starmath/inc/pch/precompiled_sm.hxx b/starmath/inc/pch/precompiled_sm.hxx
index ca384df..c6c3a5f 100644
--- a/starmath/inc/pch/precompiled_sm.hxx
+++ b/starmath/inc/pch/precompiled_sm.hxx
@@ -35,7 +35,7 @@
#include <string_view>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index d96300b..23f4c6c 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -997,7 +997,7 @@ bool SmTextForwarder::IsValid() const
    return pEditEngine && pEditEngine->GetUpdateMode();
}

OUString SmTextForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor )
OUString SmTextForwarder::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor )
{
    EditEngine *pEditEngine = rEditAcc.GetEditEngine();
    return pEditEngine ? pEditEngine->CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor) : OUString();
diff --git a/starmath/source/accessibility.hxx b/starmath/source/accessibility.hxx
index 8dcf6a01..dceff88 100644
--- a/starmath/source/accessibility.hxx
+++ b/starmath/source/accessibility.hxx
@@ -197,7 +197,7 @@ public:

    virtual SfxItemPool* GetPool() const override;

    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor ) override;
    virtual OUString        CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor ) override;
    virtual void            FieldClicked(const SvxFieldItem&) override;
    virtual bool            IsValid() const override;

diff --git a/svgio/inc/svgnode.hxx b/svgio/inc/svgnode.hxx
index 697c8c3..9db4f47 100644
--- a/svgio/inc/svgnode.hxx
+++ b/svgio/inc/svgnode.hxx
@@ -27,7 +27,7 @@
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <memory>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

// predefines
namespace svgio
@@ -95,10 +95,10 @@ namespace svgio
            std::vector< std::unique_ptr<SvgNode> >  maChildren;

            /// Id svan value
            boost::optional<OUString>   mpId;
            o3tl::optional<OUString>   mpId;

            /// Class svan value
            boost::optional<OUString>   mpClass;
            o3tl::optional<OUString>   mpClass;

            /// XmlSpace value
            XmlSpace                    maXmlSpace;
@@ -168,11 +168,11 @@ namespace svgio
            double getCurrentXHeight() const;

            /// Id access
            boost::optional<OUString> const & getId() const { return mpId; }
            o3tl::optional<OUString> const & getId() const { return mpId; }
            void setId(OUString const &);

            /// Class access
            boost::optional<OUString> const & getClass() const { return mpClass; }
            o3tl::optional<OUString> const & getClass() const { return mpClass; }
            void setClass(OUString const &);

            /// XmlSpace access
diff --git a/svl/inc/pch/precompiled_svl.hxx b/svl/inc/pch/precompiled_svl.hxx
index 7b5f510..394bf91 100644
--- a/svl/inc/pch/precompiled_svl.hxx
+++ b/svl/inc/pch/precompiled_svl.hxx
@@ -33,7 +33,7 @@
#include <string_view>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/json_parser.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/svtools/inc/pch/precompiled_svt.hxx b/svtools/inc/pch/precompiled_svt.hxx
index 156ae9c..70ab875 100644
--- a/svtools/inc/pch/precompiled_svt.hxx
+++ b/svtools/inc/pch/precompiled_svt.hxx
@@ -48,7 +48,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/svtools/source/misc/sampletext.cxx b/svtools/source/misc/sampletext.cxx
index 1d85d4a..e62da16 100644
--- a/svtools/source/misc/sampletext.cxx
+++ b/svtools/source/misc/sampletext.cxx
@@ -705,7 +705,7 @@ static OUString makeRepresentativeTextForLanguage(LanguageType eLang)
namespace
{
#if OSL_DEBUG_LEVEL > 0
    void lcl_dump_unicode_coverage(const boost::optional<std::bitset<vcl::UnicodeCoverage::MAX_UC_ENUM>> &roIn)
    void lcl_dump_unicode_coverage(const o3tl::optional<std::bitset<vcl::UnicodeCoverage::MAX_UC_ENUM>> &roIn)
    {
        if (!roIn)
        {
@@ -976,7 +976,7 @@ namespace
            SAL_INFO("svtools", "RESERVED5");
    }

    void lcl_dump_codepage_coverage(const boost::optional<std::bitset<vcl::CodePageCoverage::MAX_CP_ENUM>> &roIn)
    void lcl_dump_codepage_coverage(const o3tl::optional<std::bitset<vcl::CodePageCoverage::MAX_CP_ENUM>> &roIn)
    {
        if (!roIn)
        {
diff --git a/svtools/source/table/gridtablerenderer.cxx b/svtools/source/table/gridtablerenderer.cxx
index 0f58e4d..f30a8e9 100644
--- a/svtools/source/table/gridtablerenderer.cxx
+++ b/svtools/source/table/gridtablerenderer.cxx
@@ -203,7 +203,7 @@ namespace svt { namespace table

    namespace
    {
        Color lcl_getEffectiveColor(boost::optional<Color> const& i_modelColor,
        Color lcl_getEffectiveColor(o3tl::optional<Color> const& i_modelColor,
                                    StyleSettings const& i_styleSettings,
                                    Color const& (StyleSettings::*i_getDefaultColor) () const)
        {
@@ -229,7 +229,7 @@ namespace svt { namespace table
        rRenderContext.DrawRect(_rArea);

        // delimiter lines at bottom/right
        boost::optional<Color> aLineColor(m_pImpl->rModel.getLineColor());
        o3tl::optional<Color> aLineColor(m_pImpl->rModel.getLineColor());
        Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
        rRenderContext.SetLineColor(lineColor);
        rRenderContext.DrawLine(_rArea.BottomLeft(), _rArea.BottomRight());
@@ -261,7 +261,7 @@ namespace svt { namespace table
            nDrawTextFlags |= DrawTextFlags::Disable;
        rRenderContext.DrawText( aTextRect, sHeaderText, nDrawTextFlags );

        boost::optional<Color> const aLineColor( m_pImpl->rModel.getLineColor() );
        o3tl::optional<Color> const aLineColor( m_pImpl->rModel.getLineColor() );
        Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
        rRenderContext.SetLineColor( lineColor );
        rRenderContext.DrawLine( _rArea.BottomRight(), _rArea.TopRight());
@@ -309,7 +309,7 @@ namespace svt { namespace table

        Color backgroundColor = _rStyle.GetFieldColor();

        boost::optional<Color> const aLineColor( m_pImpl->rModel.getLineColor() );
        o3tl::optional<Color> const aLineColor( m_pImpl->rModel.getLineColor() );
        Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;

        Color const activeSelectionBackColor = lcl_getEffectiveColor(m_pImpl->rModel.getActiveSelectionBackColor(),
@@ -325,7 +325,7 @@ namespace svt { namespace table
        }
        else
        {
            boost::optional< std::vector<Color> > aRowColors = m_pImpl->rModel.getRowBackgroundColors();
            o3tl::optional< std::vector<Color> > aRowColors = m_pImpl->rModel.getRowBackgroundColors();
            if (!aRowColors)
            {
                // use alternating default colors
@@ -370,7 +370,7 @@ namespace svt { namespace table
    {
        rRenderContext.Push( PushFlags::LINECOLOR | PushFlags::TEXTCOLOR );

        boost::optional<Color> const aLineColor( m_pImpl->rModel.getLineColor() );
        o3tl::optional<Color> const aLineColor( m_pImpl->rModel.getLineColor() );
        Color const lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;
        rRenderContext.SetLineColor(lineColor);
        rRenderContext.DrawLine(_rArea.BottomLeft(), _rArea.BottomRight());
@@ -428,7 +428,7 @@ namespace svt { namespace table

        if ( m_pImpl->bUseGridLines )
        {
            ::boost::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() );
            ::o3tl::optional< ::Color > aLineColor( m_pImpl->rModel.getLineColor() );
            ::Color lineColor = !aLineColor ? _rStyle.GetSeparatorColor() : *aLineColor;

            if ( _bSelected && !aLineColor )
diff --git a/svtools/source/table/tablecontrol_impl.cxx b/svtools/source/table/tablecontrol_impl.cxx
index 8dfaf9d..42e65a0 100644
--- a/svtools/source/table/tablecontrol_impl.cxx
+++ b/svtools/source/table/tablecontrol_impl.cxx
@@ -149,45 +149,45 @@ namespace svt { namespace table
        }
        virtual void addTableModelListener( const PTableModelListener& ) override {}
        virtual void removeTableModelListener( const PTableModelListener& ) override {}
        virtual ::boost::optional< ::Color > getLineColor() const override
        virtual ::o3tl::optional< ::Color > getLineColor() const override
        {
            return ::boost::optional< ::Color >();
            return ::o3tl::optional< ::Color >();
        }
        virtual ::boost::optional< ::Color > getHeaderBackgroundColor() const override
        virtual ::o3tl::optional< ::Color > getHeaderBackgroundColor() const override
        {
            return ::boost::optional< ::Color >();
            return ::o3tl::optional< ::Color >();
        }
        virtual ::boost::optional< ::Color > getHeaderTextColor() const override
        virtual ::o3tl::optional< ::Color > getHeaderTextColor() const override
        {
            return ::boost::optional< ::Color >();
            return ::o3tl::optional< ::Color >();
        }
        virtual ::boost::optional< ::Color >    getActiveSelectionBackColor() const override
        virtual ::o3tl::optional< ::Color >    getActiveSelectionBackColor() const override
        {
            return ::boost::optional< ::Color >();
            return ::o3tl::optional< ::Color >();
        }
        virtual ::boost::optional< ::Color >    getInactiveSelectionBackColor() const override
        virtual ::o3tl::optional< ::Color >    getInactiveSelectionBackColor() const override
        {
            return ::boost::optional< ::Color >();
            return ::o3tl::optional< ::Color >();
        }
        virtual ::boost::optional< ::Color >    getActiveSelectionTextColor() const override
        virtual ::o3tl::optional< ::Color >    getActiveSelectionTextColor() const override
        {
            return ::boost::optional< ::Color >();
            return ::o3tl::optional< ::Color >();
        }
        virtual ::boost::optional< ::Color >    getInactiveSelectionTextColor() const override
        virtual ::o3tl::optional< ::Color >    getInactiveSelectionTextColor() const override
        {
            return ::boost::optional< ::Color >();
            return ::o3tl::optional< ::Color >();
        }
        virtual ::boost::optional< ::Color > getTextColor() const override
        virtual ::o3tl::optional< ::Color > getTextColor() const override
        {
            return ::boost::optional< ::Color >();
            return ::o3tl::optional< ::Color >();
        }
        virtual ::boost::optional< ::Color > getTextLineColor() const override
        virtual ::o3tl::optional< ::Color > getTextLineColor() const override
        {
            return ::boost::optional< ::Color >();
            return ::o3tl::optional< ::Color >();
        }
        virtual ::boost::optional< ::std::vector< ::Color > > getRowBackgroundColors() const override
        virtual ::o3tl::optional< ::std::vector< ::Color > > getRowBackgroundColors() const override
        {
            return ::boost::optional< ::std::vector< ::Color > >();
            return ::o3tl::optional< ::std::vector< ::Color > >();
        }
        virtual css::style::VerticalAlignment getVerticalAlign() const override
        {
diff --git a/svtools/source/uno/svtxgridcontrol.cxx b/svtools/source/uno/svtxgridcontrol.cxx
index 98c212e..31f46d0 100644
--- a/svtools/source/uno/svtxgridcontrol.cxx
+++ b/svtools/source/uno/svtxgridcontrol.cxx
@@ -452,7 +452,7 @@ void SVTXGridControl::impl_checkTableModelInit()

namespace
{
    void lcl_convertColor( ::boost::optional< ::Color > const & i_color, Any & o_colorValue )
    void lcl_convertColor( ::o3tl::optional< ::Color > const & i_color, Any & o_colorValue )
    {
        if ( !i_color )
            o_colorValue.clear();
@@ -535,7 +535,7 @@ Any SVTXGridControl::getProperty( const OUString& PropertyName )

    case BASEPROPERTY_GRID_ROW_BACKGROUND_COLORS:
    {
        ::boost::optional< ::std::vector< ::Color > > aColors( m_xTableModel->getRowBackgroundColors() );
        ::o3tl::optional< ::std::vector< ::Color > > aColors( m_xTableModel->getRowBackgroundColors() );
        if ( !aColors )
            aPropertyValue.clear();
        else
diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx
index 9962969..dce3b90 100644
--- a/svtools/source/uno/unocontroltablemodel.cxx
+++ b/svtools/source/uno/unocontroltablemodel.cxx
@@ -70,16 +70,16 @@ namespace svt { namespace table
        TableMetrics                                    nRowHeight;
        TableMetrics                                    nColumnHeaderHeight;
        TableMetrics                                    nRowHeaderWidth;
        ::boost::optional< ::Color >                    m_aGridLineColor;
        ::boost::optional< ::Color >                    m_aHeaderBackgroundColor;
        ::boost::optional< ::Color >                    m_aHeaderTextColor;
        ::boost::optional< ::Color >                    m_aActiveSelectionBackColor;
        ::boost::optional< ::Color >                    m_aInactiveSelectionBackColor;
        ::boost::optional< ::Color >                    m_aActiveSelectionTextColor;
        ::boost::optional< ::Color >                    m_aInactiveSelectionTextColor;
        ::boost::optional< ::Color >                    m_aTextColor;
        ::boost::optional< ::Color >                    m_aTextLineColor;
        ::boost::optional< ::std::vector< ::Color > >   m_aRowColors;
        ::o3tl::optional< ::Color >                    m_aGridLineColor;
        ::o3tl::optional< ::Color >                    m_aHeaderBackgroundColor;
        ::o3tl::optional< ::Color >                    m_aHeaderTextColor;
        ::o3tl::optional< ::Color >                    m_aActiveSelectionBackColor;
        ::o3tl::optional< ::Color >                    m_aInactiveSelectionBackColor;
        ::o3tl::optional< ::Color >                    m_aActiveSelectionTextColor;
        ::o3tl::optional< ::Color >                    m_aInactiveSelectionTextColor;
        ::o3tl::optional< ::Color >                    m_aTextColor;
        ::o3tl::optional< ::Color >                    m_aTextLineColor;
        ::o3tl::optional< ::std::vector< ::Color > >   m_aRowColors;
        VerticalAlignment                               m_eVerticalAlign;
        bool                                            bEnabled;
        ModellListeners                                 m_aListeners;
@@ -532,7 +532,7 @@ namespace svt { namespace table

    namespace
    {
        void lcl_setColor( Any const & i_color, ::boost::optional< ::Color > & o_convertedColor )
        void lcl_setColor( Any const & i_color, ::o3tl::optional< ::Color > & o_convertedColor )
        {
            if ( !i_color.hasValue() )
                o_convertedColor.reset();
@@ -552,7 +552,7 @@ namespace svt { namespace table
    }


    ::boost::optional< ::Color > UnoControlTableModel::getLineColor() const
    ::o3tl::optional< ::Color > UnoControlTableModel::getLineColor() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aGridLineColor;
@@ -566,7 +566,7 @@ namespace svt { namespace table
    }


    ::boost::optional< ::Color > UnoControlTableModel::getHeaderBackgroundColor() const
    ::o3tl::optional< ::Color > UnoControlTableModel::getHeaderBackgroundColor() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aHeaderBackgroundColor;
@@ -580,35 +580,35 @@ namespace svt { namespace table
    }


    ::boost::optional< ::Color > UnoControlTableModel::getHeaderTextColor() const
    ::o3tl::optional< ::Color > UnoControlTableModel::getHeaderTextColor() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aHeaderTextColor;
    }


    ::boost::optional< ::Color > UnoControlTableModel::getActiveSelectionBackColor() const
    ::o3tl::optional< ::Color > UnoControlTableModel::getActiveSelectionBackColor() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aActiveSelectionBackColor;
    }


    ::boost::optional< ::Color > UnoControlTableModel::getInactiveSelectionBackColor() const
    ::o3tl::optional< ::Color > UnoControlTableModel::getInactiveSelectionBackColor() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aInactiveSelectionBackColor;
    }


    ::boost::optional< ::Color > UnoControlTableModel::getActiveSelectionTextColor() const
    ::o3tl::optional< ::Color > UnoControlTableModel::getActiveSelectionTextColor() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aActiveSelectionTextColor;
    }


    ::boost::optional< ::Color > UnoControlTableModel::getInactiveSelectionTextColor() const
    ::o3tl::optional< ::Color > UnoControlTableModel::getInactiveSelectionTextColor() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aInactiveSelectionTextColor;
@@ -650,7 +650,7 @@ namespace svt { namespace table
    }


    ::boost::optional< ::Color > UnoControlTableModel::getTextColor() const
    ::o3tl::optional< ::Color > UnoControlTableModel::getTextColor() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aTextColor;
@@ -664,7 +664,7 @@ namespace svt { namespace table
    }


    ::boost::optional< ::Color > UnoControlTableModel::getTextLineColor() const
    ::o3tl::optional< ::Color > UnoControlTableModel::getTextLineColor() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aTextColor;
@@ -678,7 +678,7 @@ namespace svt { namespace table
    }


    ::boost::optional< ::std::vector< ::Color > > UnoControlTableModel::getRowBackgroundColors() const
    ::o3tl::optional< ::std::vector< ::Color > > UnoControlTableModel::getRowBackgroundColors() const
    {
        DBG_CHECK_ME();
        return m_pImpl->m_aRowColors;
diff --git a/svtools/source/uno/unocontroltablemodel.hxx b/svtools/source/uno/unocontroltablemodel.hxx
index f874542..feb63c1 100644
--- a/svtools/source/uno/unocontroltablemodel.hxx
+++ b/svtools/source/uno/unocontroltablemodel.hxx
@@ -68,16 +68,16 @@ namespace svt { namespace table
        virtual void                            getCellContent( ColPos const i_col, RowPos const i_row, css::uno::Any& o_cellContent ) override;
        virtual void                            getCellToolTip( ColPos const i_col, RowPos const i_row, css::uno::Any & o_cellToolTip ) override;
        virtual css::uno::Any      getRowHeading( RowPos const i_rowPos ) const override;
        virtual ::boost::optional< ::Color >    getLineColor() const override;
        virtual ::boost::optional< ::Color >    getHeaderBackgroundColor() const override;
        virtual ::boost::optional< ::Color >    getHeaderTextColor() const override;
        virtual ::boost::optional< ::Color >    getActiveSelectionBackColor() const override;
        virtual ::boost::optional< ::Color >    getInactiveSelectionBackColor() const override;
        virtual ::boost::optional< ::Color >    getActiveSelectionTextColor() const override;
        virtual ::boost::optional< ::Color >    getInactiveSelectionTextColor() const override;
        virtual ::boost::optional< ::Color >    getTextColor() const override;
        virtual ::boost::optional< ::Color >    getTextLineColor() const override;
        virtual ::boost::optional< ::std::vector< ::Color > >
        virtual ::o3tl::optional< ::Color >    getLineColor() const override;
        virtual ::o3tl::optional< ::Color >    getHeaderBackgroundColor() const override;
        virtual ::o3tl::optional< ::Color >    getHeaderTextColor() const override;
        virtual ::o3tl::optional< ::Color >    getActiveSelectionBackColor() const override;
        virtual ::o3tl::optional< ::Color >    getInactiveSelectionBackColor() const override;
        virtual ::o3tl::optional< ::Color >    getActiveSelectionTextColor() const override;
        virtual ::o3tl::optional< ::Color >    getInactiveSelectionTextColor() const override;
        virtual ::o3tl::optional< ::Color >    getTextColor() const override;
        virtual ::o3tl::optional< ::Color >    getTextLineColor() const override;
        virtual ::o3tl::optional< ::std::vector< ::Color > >
                                                getRowBackgroundColors() const override;
        virtual css::style::VerticalAlignment
                                                getVerticalAlign() const override;
diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx
index 0de6708..3a99ad7 100644
--- a/svx/inc/pch/precompiled_svx.hxx
+++ b/svx/inc/pch/precompiled_svx.hxx
@@ -41,7 +41,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/svx/inc/pch/precompiled_svxcore.hxx b/svx/inc/pch/precompiled_svxcore.hxx
index ea9506e..a03b6f3 100644
--- a/svx/inc/pch/precompiled_svxcore.hxx
+++ b/svx/inc/pch/precompiled_svxcore.hxx
@@ -49,7 +49,7 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/svx/source/accessibility/AccessibleEmptyEditSource.cxx b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
index a0a31d9..297315a 100644
--- a/svx/source/accessibility/AccessibleEmptyEditSource.cxx
+++ b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
@@ -121,7 +121,7 @@ namespace accessibility
        //XTextCopy
        void        CopyText(const SvxTextForwarder& ) override {}

        OUString    CalcFieldValue( const SvxFieldItem& /*rField*/, sal_Int32 /*nPara*/, sal_Int32 /*nPos*/, boost::optional<Color>& /*rpTxtColor*/, boost::optional<Color>& /*rpFldColor*/ ) override
        OUString    CalcFieldValue( const SvxFieldItem& /*rField*/, sal_Int32 /*nPara*/, sal_Int32 /*nPos*/, o3tl::optional<Color>& /*rpTxtColor*/, o3tl::optional<Color>& /*rpFldColor*/ ) override
        {
            return  OUString();
        }
diff --git a/svx/source/dialog/ClassificationEditView.cxx b/svx/source/dialog/ClassificationEditView.cxx
index bc22666..6eba6e6 100644
--- a/svx/source/dialog/ClassificationEditView.cxx
+++ b/svx/source/dialog/ClassificationEditView.cxx
@@ -30,7 +30,7 @@ ClassificationEditEngine::ClassificationEditEngine(SfxItemPool* pItemPool)
{}

OUString ClassificationEditEngine::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 /*nPara*/,
                                                  sal_Int32 /*nPos*/, boost::optional<Color>& /*rTxtColor*/, boost::optional<Color>& /*rFldColor*/)
                                                  sal_Int32 /*nPos*/, o3tl::optional<Color>& /*rTxtColor*/, o3tl::optional<Color>& /*rFldColor*/)
{
    OUString aString;
    const ClassificationField* pClassificationField = dynamic_cast<const ClassificationField*>(rField.GetField());
diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx
index 0d0173f..222a3db 100644
--- a/svx/source/dialog/weldeditview.cxx
+++ b/svx/source/dialog/weldeditview.cxx
@@ -241,8 +241,8 @@ public:
    virtual SfxItemPool* GetPool() const override;

    virtual OUString CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
                                    boost::optional<Color>& rpTxtColor,
                                    boost::optional<Color>& rpFldColor) override;
                                    o3tl::optional<Color>& rpTxtColor,
                                    o3tl::optional<Color>& rpFldColor) override;
    virtual void FieldClicked(const SvxFieldItem&) override;
    virtual bool IsValid() const override;

@@ -905,8 +905,8 @@ bool WeldTextForwarder::IsValid() const
}

OUString WeldTextForwarder::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara,
                                           sal_Int32 nPos, boost::optional<Color>& rpTxtColor,
                                           boost::optional<Color>& rpFldColor)
                                           sal_Int32 nPos, o3tl::optional<Color>& rpTxtColor,
                                           o3tl::optional<Color>& rpFldColor)
{
    EditEngine* pEditEngine = m_rEditAcc.GetEditEngine();
    return pEditEngine ? pEditEngine->CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor)
diff --git a/svx/source/form/fmmodel.cxx b/svx/source/form/fmmodel.cxx
index 3791cb7..5942abf 100644
--- a/svx/source/form/fmmodel.cxx
+++ b/svx/source/form/fmmodel.cxx
@@ -28,7 +28,7 @@

#include <sfx2/objsh.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

using ::com::sun::star::uno::Reference;
using ::com::sun::star::container::XNameContainer;
@@ -39,7 +39,7 @@ struct FmFormModelImplData
{
    rtl::Reference<FmXUndoEnvironment>  mxUndoEnv;
    bool                bOpenInDesignIsDefaulted;
    boost::optional<bool> aControlsUseRefDevice;
    o3tl::optional<bool> aControlsUseRefDevice;

    FmFormModelImplData()
        :bOpenInDesignIsDefaulted( true )
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index bafc02d..f6861bd 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1012,8 +1012,8 @@ IMPL_LINK(SdrObjEditView, ImpOutlinerCalcFieldValueHdl, EditFieldInfo*, pFI, voi
    SdrTextObj* pTextObj = mxTextEditObj.get();
    if (pTextObj != nullptr)
    {
        boost::optional<Color> pTxtCol;
        boost::optional<Color> pFldCol;
        o3tl::optional<Color> pTxtCol;
        o3tl::optional<Color> pFldCol;
        bOk = pTextObj->CalcFieldValue(pFI->GetField(), pFI->GetPara(), pFI->GetPos(), true,
                                       pTxtCol, pFldCol, rStr);
        if (bOk)
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 3758426..28fb05e 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -138,7 +138,7 @@

#include <unordered_set>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <libxml/xmlwriter.h>
#include <memory>

@@ -207,9 +207,9 @@ struct SdrObject::Impl
{
    sdr::ObjectUserVector maObjectUsers;

    boost::optional<double> mnRelativeWidth;
    o3tl::optional<double> mnRelativeWidth;
    sal_Int16               meRelativeWidthRelation;
    boost::optional<double> mnRelativeHeight;
    o3tl::optional<double> mnRelativeHeight;
    sal_Int16               meRelativeHeightRelation;

    std::shared_ptr<DiagramDataInterface> mpDiagramData;
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index ca047cd..e950dc8 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -550,7 +550,7 @@ basegfx::B2DPolyPolygon SdrMeasureObj::ImpCalcXPoly(const ImpMeasurePoly& rPol)

bool SdrMeasureObj::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
    bool bEdit,
    boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor, OUString& rRet) const
    o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor, OUString& rRet) const
{
    const SvxFieldData* pField=rField.GetField();
    const SdrMeasureField* pMeasureField=dynamic_cast<const SdrMeasureField*>( pField );
diff --git a/svx/source/svdraw/svdotxfl.cxx b/svx/source/svdraw/svdotxfl.cxx
index c8e8271..11fe15d 100644
--- a/svx/source/svdraw/svdotxfl.cxx
+++ b/svx/source/svdraw/svdotxfl.cxx
@@ -22,7 +22,7 @@
#include <svx/svdotext.hxx>

bool SdrTextObj::CalcFieldValue(const SvxFieldItem& /*rField*/, sal_Int32 /*nPara*/, sal_uInt16 /*nPos*/,
    bool /*bEdit*/, boost::optional<Color>& /*rpTxtColor*/, boost::optional<Color>& /*rpFldColor*/, OUString& /*rRet*/) const
    bool /*bEdit*/, o3tl::optional<Color>& /*rpTxtColor*/, o3tl::optional<Color>& /*rpFldColor*/, OUString& /*rRet*/) const
{
    return false;
}
diff --git a/svx/source/svdraw/svdoutl.cxx b/svx/source/svdraw/svdoutl.cxx
index 0387afa..31fb093 100644
--- a/svx/source/svdraw/svdoutl.cxx
+++ b/svx/source/svdraw/svdoutl.cxx
@@ -72,7 +72,7 @@ void SdrOutliner::SetTextObjNoInit( const SdrTextObj* pObj )
}

OUString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
                                     boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor)
                                     o3tl::optional<Color>& rpTxtColor, o3tl::optional<Color>& rpFldColor)
{
    bool bOk = false;
    OUString aRet;
diff --git a/sw/inc/anchoreddrawobject.hxx b/sw/inc/anchoreddrawobject.hxx
index 8f38334..2524994 100644
--- a/sw/inc/anchoreddrawobject.hxx
+++ b/sw/inc/anchoreddrawobject.hxx
@@ -20,7 +20,7 @@
#define INCLUDED_SW_INC_ANCHOREDDRAWOBJECT_HXX

#include "anchoredobject.hxx"
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace tools { class Rectangle; }

@@ -33,7 +33,7 @@ class SwAnchoredDrawObject final : public SwAnchoredObject
        bool mbValidPos;

        // rectangle, keeping the last object rectangle after the positioning
        boost::optional<tools::Rectangle> maLastObjRect;
        o3tl::optional<tools::Rectangle> maLastObjRect;

        // boolean, indicating that anchored drawing object hasn't been attached
        // to an anchor frame yet. Once, it is attached to an anchor frame the
@@ -120,7 +120,7 @@ class SwAnchoredDrawObject final : public SwAnchoredObject
        // accessors to the object area and its position
        virtual SwRect GetObjRect() const override;

        boost::optional<tools::Rectangle> const & GetLastObjRect() const { return maLastObjRect;}
        o3tl::optional<tools::Rectangle> const & GetLastObjRect() const { return maLastObjRect;}
        void SetLastObjRect( const tools::Rectangle& _rNewObjRect );

        /** adjust positioning and alignment attributes for new anchor frame
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 23b3753..daf784a 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -129,7 +129,7 @@ bool ReplaceImpl(SwPaM & rCursor, OUString const& rReplacement,
        bool const bRegExp, SwDoc & rDoc, SwRootFrame const*const pLayout);

/// Helperfunction to resolve backward references in regular expressions
boost::optional<OUString> ReplaceBackReferences(const i18nutil::SearchOptions2& rSearchOpt,
o3tl::optional<OUString> ReplaceBackReferences(const i18nutil::SearchOptions2& rSearchOpt,
        SwPaM* pPam, SwRootFrame const* pLayout );

bool GetRanges(std::vector<std::shared_ptr<SwUnoCursor>> & rRanges,
diff --git a/sw/inc/fmtpdsc.hxx b/sw/inc/fmtpdsc.hxx
index 4b99ccb..1db8059 100644
--- a/sw/inc/fmtpdsc.hxx
+++ b/sw/inc/fmtpdsc.hxx
@@ -24,7 +24,7 @@
#include "hintids.hxx"
#include "format.hxx"
#include "calbck.hxx"
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include "pagedesc.hxx"

class IntlWrapper;
@@ -34,7 +34,7 @@ class IntlWrapper;

class SW_DLLPUBLIC SwFormatPageDesc : public SfxPoolItem, public SwClient
{
    ::boost::optional<sal_uInt16> m_oNumOffset;          ///< Offset page number.
    ::o3tl::optional<sal_uInt16> m_oNumOffset;          ///< Offset page number.
    SwModify* m_pDefinedIn;       /**< Points to the object in which the
                                 attribute was set (ContentNode/Format). */
protected:
@@ -62,8 +62,8 @@ public:
          SwPageDesc *GetPageDesc() { return static_cast<SwPageDesc*>(GetRegisteredIn()); }
    const SwPageDesc *GetPageDesc() const { return static_cast<const SwPageDesc*>(GetRegisteredIn()); }

    const ::boost::optional<sal_uInt16>&  GetNumOffset() const        { return m_oNumOffset; }
    void    SetNumOffset( const ::boost::optional<sal_uInt16>& oNum ) { m_oNumOffset = oNum; }
    const ::o3tl::optional<sal_uInt16>&  GetNumOffset() const        { return m_oNumOffset; }
    void    SetNumOffset( const ::o3tl::optional<sal_uInt16>& oNum ) { m_oNumOffset = oNum; }

    /// Query / set where attribute is anchored.
    const SwModify* GetDefinedIn() const { return m_pDefinedIn; }
diff --git a/sw/inc/pch/precompiled_msword.hxx b/sw/inc/pch/precompiled_msword.hxx
index c403018..6eb4c4c 100644
--- a/sw/inc/pch/precompiled_msword.hxx
+++ b/sw/inc/pch/precompiled_msword.hxx
@@ -53,7 +53,7 @@
#include <unordered_set>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx
index 37bcf74..b9fb0e0 100644
--- a/sw/inc/pch/precompiled_sw.hxx
+++ b/sw/inc/pch/precompiled_sw.hxx
@@ -46,8 +46,8 @@
#include <utility>
#include <vector>
#include <boost/circular_buffer.hpp>
#include <boost/optional.hpp>
#include <boost/optional/optional.hpp>
#include <o3tl/optional.hxx>
#include <o3tl/optional.hxx>
#include <boost/property_tree/json_parser.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/sw/inc/pch/precompiled_swui.hxx b/sw/inc/pch/precompiled_swui.hxx
index 3db3571..48f81b6 100644
--- a/sw/inc/pch/precompiled_swui.hxx
+++ b/sw/inc/pch/precompiled_swui.hxx
@@ -52,7 +52,7 @@
#include <typeinfo>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/sw/inc/pch/precompiled_vbaswobj.hxx b/sw/inc/pch/precompiled_vbaswobj.hxx
index 7b6b4f9..d0a0f44 100644
--- a/sw/inc/pch/precompiled_vbaswobj.hxx
+++ b/sw/inc/pch/precompiled_vbaswobj.hxx
@@ -61,7 +61,7 @@
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/random_access_index.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index b35353f..8503eca 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -29,7 +29,7 @@
#include <cstddef>
#include <memory>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>


class SfxItemSet;
@@ -158,7 +158,7 @@ class SW_DLLPUBLIC SwRangeRedline : public SwPaM
    bool m_bIsVisible : 1;
    sal_uInt32 const m_nId;

    boost::optional<long> m_oLOKLastNodeTop;
    o3tl::optional<long> m_oLOKLastNodeTop;

    void MoveToSection();
    void CopyToSection();
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index 3d4dd0d..dfe31d8 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -23,7 +23,7 @@
#include <sfx2/sfxdlg.hxx>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Sequence.h>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include "dbmgr.hxx"
#include <cnttab.hxx>
#include "tblenum.hxx"
@@ -232,7 +232,7 @@ protected:
public:
    virtual OUString                        GetTemplateName() = 0;
    virtual sal_uInt16                      GetKind() = 0;
    virtual ::boost::optional<sal_uInt16>   GetPageNumber() = 0;
    virtual ::o3tl::optional<sal_uInt16>   GetPageNumber() = 0;

};

diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index d98507d..dc271d0 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -27,7 +27,7 @@
#include "SwRewriter.hxx"
#include "swundo.hxx"
#include <o3tl/typed_flags_set.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class SwHistory;
class SwPaM;
@@ -58,7 +58,7 @@ class SwUndo

protected:
    bool m_bCacheComment;
    mutable boost::optional<OUString> maComment;
    mutable o3tl::optional<OUString> maComment;

    static void RemoveIdxFromSection( SwDoc&, sal_uLong nSttIdx, const sal_uLong* pEndIdx = nullptr );
    static void RemoveIdxFromRange( SwPaM& rPam, bool bMoveNext );
diff --git a/sw/source/core/crsr/BlockCursor.hxx b/sw/source/core/crsr/BlockCursor.hxx
index 805b4a9..dfbb71a 100644
--- a/sw/source/core/crsr/BlockCursor.hxx
+++ b/sw/source/core/crsr/BlockCursor.hxx
@@ -19,7 +19,7 @@
#ifndef INCLUDED_SW_SOURCE_CORE_CRSR_BLOCKCURSOR_HXX
#define INCLUDED_SW_SOURCE_CORE_CRSR_BLOCKCURSOR_HXX

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <tools/gen.hxx>

#include <viscrs.hxx>
@@ -39,8 +39,8 @@ struct SwPosition;
class SwBlockCursor
{
    SwShellCursor maCursor;
    boost::optional<Point> maStartPt;
    boost::optional<Point> maEndPt;
    o3tl::optional<Point> maStartPt;
    o3tl::optional<Point> maEndPt;

public:
    SwBlockCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos ) :
@@ -69,12 +69,12 @@ public:

        @return 0, if no start point has been set
    */
    boost::optional<Point> const & getStartPoint() const { return maStartPt; }
    o3tl::optional<Point> const & getStartPoint() const { return maStartPt; }
    /** The document coordinates where the block selection ends (at the moment)

        @return 0, if no end point has been set
    */
    boost::optional<Point> const & getEndPoint() const { return maEndPt; }
    o3tl::optional<Point> const & getEndPoint() const { return maEndPt; }
    /** Deletion of the mouse created rectangle

        When start and end points exist, the block cursor depends on this. If the
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index a16713d..e5c879b 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -55,7 +55,7 @@ namespace sw { namespace mark
        sal_uLong const nStartNode(rStartPos.nNode.GetIndex());
        sal_uLong const nEndNode(rEndPos.nNode.GetIndex());
        int nFields(0);
        boost::optional<SwPosition> ret;
        o3tl::optional<SwPosition> ret;
        for (sal_uLong n = nEndNode; nStartNode <= n; --n)
        {
            SwNode *const pNode(rNodes[n]);
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index 3755a46..1709efb 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -40,7 +40,7 @@
#include <pamtyp.hxx>
#include <txtfrm.hxx>
#include <swundo.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <algorithm>
#include <memory>
@@ -65,9 +65,9 @@ static bool CmpAttr( const SfxPoolItem& rItem1, const SfxPoolItem& rItem2 )
                                static_cast<const SvxColorItem&>(rItem2).GetValue() );
    case RES_PAGEDESC:
        bool bNumOffsetEqual = false;
        ::boost::optional<sal_uInt16> const oNumOffset1 =
        ::o3tl::optional<sal_uInt16> const oNumOffset1 =
            static_cast<const SwFormatPageDesc&>(rItem1).GetNumOffset();
        ::boost::optional<sal_uInt16> const oNumOffset2 =
        ::o3tl::optional<sal_uInt16> const oNumOffset2 =
            static_cast<const SwFormatPageDesc&>(rItem2).GetNumOffset();
        if (!oNumOffset1 && !oNumOffset2)
        {
@@ -1315,7 +1315,7 @@ int SwFindParaAttr::DoFind(SwPaM & rCursor, SwMoveFnCollection const & fnMove,
            const_cast<SwPaM &>(rRegion).GetRingContainer().merge( m_rCursor.GetRingContainer() );
        }

        boost::optional<OUString> xRepl;
        o3tl::optional<OUString> xRepl;
        if (bRegExp)
            xRepl = sw::ReplaceBackReferences(*pSearchOpt, &rCursor, m_pLayout);
        sw::ReplaceImpl(rCursor,
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index d9658bc..729fef6 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -139,7 +139,7 @@ public:

class MaybeMergedIter
{
    boost::optional<sw::MergedAttrIter> m_oMergedIter;
    o3tl::optional<sw::MergedAttrIter> m_oMergedIter;
    SwTextNode const*const m_pNode;
    size_t m_HintIndex;

@@ -950,7 +950,7 @@ int SwFindParaText::DoFind(SwPaM & rCursor, SwMoveFnCollection const & fnMove,
            const_cast<SwPaM&>(rRegion).GetRingContainer().merge( m_rCursor.GetRingContainer() );
        }

        boost::optional<OUString> xRepl;
        o3tl::optional<OUString> xRepl;
        if (bRegExp)
            xRepl = sw::ReplaceBackReferences(m_rSearchOpt, &rCursor, m_pLayout);
        bool const bReplaced = sw::ReplaceImpl(rCursor,
@@ -1093,10 +1093,10 @@ bool ReplaceImpl(
    return bReplaced;
}

boost::optional<OUString> ReplaceBackReferences(const i18nutil::SearchOptions2& rSearchOpt,
o3tl::optional<OUString> ReplaceBackReferences(const i18nutil::SearchOptions2& rSearchOpt,
        SwPaM *const pPam, SwRootFrame const*const pLayout)
{
    boost::optional<OUString> xRet;
    o3tl::optional<OUString> xRet;
    if( pPam && pPam->HasMark() &&
        SearchAlgorithms2::REGEXP == rSearchOpt.AlgorithmType2 )
    {
diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx
index 05a4384..94b71b2 100644
--- a/sw/source/core/doc/docdraw.cxx
+++ b/sw/source/core/doc/docdraw.cxx
@@ -525,7 +525,7 @@ IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo*, pInfo, void)
    else if (dynamic_cast<const SdrMeasureField*>( pField))
    {
        // Clear measure field
        pInfo->SetFieldColor(boost::optional<Color>());
        pInfo->SetFieldColor(o3tl::optional<Color>());
    }
    else if ( auto pTimeField = dynamic_cast<const SvxExtTimeField*>( pField) )
    {
diff --git a/sw/source/core/frmedt/fedesc.cxx b/sw/source/core/frmedt/fedesc.cxx
index 55c81cc..ac914db 100644
--- a/sw/source/core/frmedt/fedesc.cxx
+++ b/sw/source/core/frmedt/fedesc.cxx
@@ -55,7 +55,7 @@ void SwFEShell::ChgCurPageDesc( const SwPageDesc& rDesc )

    SwPageFrame *pPage = GetCurrFrame()->FindPageFrame();
    const SwFrame *pFlow = nullptr;
    ::boost::optional<sal_uInt16> oPageNumOffset;
    ::o3tl::optional<sal_uInt16> oPageNumOffset;

    OSL_ENSURE( !GetCursor()->HasMark(), "ChgCurPageDesc only without selection!");

diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index f6b338b..0f0d070 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -408,7 +408,7 @@ sal_uInt16 SwFEShell::GetPageOffset() const
        {
            if ( pFlow->IsInTab() )
                pFlow = pFlow->FindTabFrame();
            ::boost::optional<sal_uInt16> oNumOffset = pFlow->GetPageDescItem().GetNumOffset();
            ::o3tl::optional<sal_uInt16> oNumOffset = pFlow->GetPageDescItem().GetNumOffset();
            if ( oNumOffset )
                return *oNumOffset;
        }
diff --git a/sw/source/core/inc/UndoDelete.hxx b/sw/source/core/inc/UndoDelete.hxx
index b9b5258..210c7f6 100644
--- a/sw/source/core/inc/UndoDelete.hxx
+++ b/sw/source/core/inc/UndoDelete.hxx
@@ -23,7 +23,7 @@
#include <undobj.hxx>
#include <rtl/ustring.hxx>
#include <memory>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class SwRedlineSaveDatas;
class SwTextNode;
@@ -38,7 +38,7 @@ class SwUndoDelete
    , private SwUndoSaveContent
{
    std::unique_ptr<SwNodeIndex> m_pMvStt;            // Position of Nodes in UndoNodes-Array
    boost::optional<OUString> m_aSttStr, m_aEndStr;
    o3tl::optional<OUString> m_aSttStr, m_aEndStr;
    std::unique_ptr<SwRedlineSaveDatas> m_pRedlSaveData;
    std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart;
    std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd;
diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx
index b290cbd..eaef360 100644
--- a/sw/source/core/inc/UndoInsert.hxx
+++ b/sw/source/core/inc/UndoInsert.hxx
@@ -27,7 +27,7 @@
#include <rtl/ustring.hxx>
#include <swtypes.hxx>
#include <IDocumentContentOperations.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class Graphic;
class SwGrfNode;
@@ -41,8 +41,8 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveContent
{
    /// start of Content in UndoNodes for Redo
    std::unique_ptr<SwNodeIndex> m_pUndoNodeIndex;
    boost::optional<OUString> maText;
    boost::optional<OUString> maUndoText;
    o3tl::optional<OUString> maText;
    o3tl::optional<OUString> maUndoText;
    std::unique_ptr<SwRedlineData> pRedlData;
    sal_uLong nNode;
    sal_Int32 nContent, nLen;
@@ -59,7 +59,7 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveContent
    SwDoc * pDoc;

    void Init(const SwNodeIndex & rNode);
    boost::optional<OUString> GetTextFromDoc() const;
    o3tl::optional<OUString> GetTextFromDoc() const;

public:
    SwUndoInsert( const SwNodeIndex& rNode, sal_Int32 nContent, sal_Int32 nLen,
@@ -135,8 +135,8 @@ private:
class SwUndoReRead : public SwUndo
{
    std::unique_ptr<Graphic> pGrf;
    boost::optional<OUString> maNm;
    boost::optional<OUString> maFltr;
    o3tl::optional<OUString> maNm;
    o3tl::optional<OUString> maFltr;
    sal_uLong nPos;
    MirrorGraph nMirr;

diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index fbec9f1..62cd74b 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -28,7 +28,7 @@
#include <swtypes.hxx>
#include "drawfont.hxx"
#include <editeng/borderline.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <o3tl/enumarray.hxx>

class SfxItemSet;
@@ -140,10 +140,10 @@ class SwFont
    Color       m_aOverColor;     // color of the overlining

    // character borders
    boost::optional<editeng::SvxBorderLine>     m_aTopBorder;
    boost::optional<editeng::SvxBorderLine>     m_aBottomBorder;
    boost::optional<editeng::SvxBorderLine>     m_aRightBorder;
    boost::optional<editeng::SvxBorderLine>     m_aLeftBorder;
    o3tl::optional<editeng::SvxBorderLine>     m_aTopBorder;
    o3tl::optional<editeng::SvxBorderLine>     m_aBottomBorder;
    o3tl::optional<editeng::SvxBorderLine>     m_aRightBorder;
    o3tl::optional<editeng::SvxBorderLine>     m_aLeftBorder;

    // border distance
    sal_uInt16 m_nTopBorderDist;
@@ -336,19 +336,19 @@ public:
    void SetRightBorder( const editeng::SvxBorderLine* pRightBorder );
    void SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder );

    const boost::optional<editeng::SvxBorderLine>& GetTopBorder() const { return m_aTopBorder; }
    const boost::optional<editeng::SvxBorderLine>& GetBottomBorder() const { return m_aBottomBorder; }
    const boost::optional<editeng::SvxBorderLine>& GetRightBorder() const { return m_aRightBorder; }
    const boost::optional<editeng::SvxBorderLine>& GetLeftBorder() const { return m_aLeftBorder; }
    const o3tl::optional<editeng::SvxBorderLine>& GetTopBorder() const { return m_aTopBorder; }
    const o3tl::optional<editeng::SvxBorderLine>& GetBottomBorder() const { return m_aBottomBorder; }
    const o3tl::optional<editeng::SvxBorderLine>& GetRightBorder() const { return m_aRightBorder; }
    const o3tl::optional<editeng::SvxBorderLine>& GetLeftBorder() const { return m_aLeftBorder; }

    // Get absolute border correspond to the layout verticality and orientation.
    const boost::optional<editeng::SvxBorderLine>&
    const o3tl::optional<editeng::SvxBorderLine>&
    GetAbsTopBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const;
    const boost::optional<editeng::SvxBorderLine>&
    const o3tl::optional<editeng::SvxBorderLine>&
    GetAbsBottomBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const;
    const boost::optional<editeng::SvxBorderLine>&
    const o3tl::optional<editeng::SvxBorderLine>&
    GetAbsRightBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const;
    const boost::optional<editeng::SvxBorderLine>&
    const o3tl::optional<editeng::SvxBorderLine>&
    GetAbsLeftBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const;

    void SetTopBorderDist( const sal_uInt16 nTopDist );
diff --git a/sw/source/core/inc/wrong.hxx b/sw/source/core/inc/wrong.hxx
index 5358172..4d063ca 100644
--- a/sw/source/core/inc/wrong.hxx
+++ b/sw/source/core/inc/wrong.hxx
@@ -29,7 +29,7 @@

#include <vector>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <tools/color.hxx>
#include <swtypes.hxx>
@@ -407,7 +407,7 @@ public:
    WrongListIteratorCounter(SwWrongList const& rWrongList);

    sal_uInt16 GetElementCount();
    boost::optional<std::pair<TextFrameIndex, TextFrameIndex>> GetElementAt(sal_uInt16 nIndex);
    o3tl::optional<std::pair<TextFrameIndex, TextFrameIndex>> GetElementAt(sal_uInt16 nIndex);
};

} // namespace sw
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 25de2a9..e214f97 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -700,7 +700,7 @@ bool SwFormatPageDesc::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
    {
        case MID_PAGEDESC_PAGENUMOFFSET:
            {
                ::boost::optional<sal_uInt16> oOffset = GetNumOffset();
                ::o3tl::optional<sal_uInt16> oOffset = GetNumOffset();
                if (oOffset)
                {
                    rVal <<= static_cast<sal_Int16>(*oOffset);
@@ -744,7 +744,7 @@ bool SwFormatPageDesc::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
            sal_Int16 nOffset = 0;
            if (!rVal.hasValue())
            {
                SetNumOffset(boost::none);
                SetNumOffset(o3tl::nullopt);
            }
            else if (rVal >>= nOffset)
                SetNumOffset( nOffset );
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index caa81ec..4c7a885 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -408,8 +408,8 @@ void SwFrame::PrepareCursor()
        std::list<FlowFrameJoinLockGuard> tabGuard;
        std::list<SwFrameDeleteGuard> rowGuard;
#else
        boost::optional<FlowFrameJoinLockGuard> tabGuard;
        boost::optional<SwFrameDeleteGuard> rowGuard;
        o3tl::optional<FlowFrameJoinLockGuard> tabGuard;
        o3tl::optional<SwFrameDeleteGuard> rowGuard;
#endif
        SwFlowFrame* pThis = bCnt ? static_cast<SwContentFrame*>(this) : nullptr;

diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index 8c1bada..af97485 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -2538,7 +2538,7 @@ bool SwFlowFrame::MoveBwd( bool &rbReformat )
#if BOOST_VERSION < 105600
            std::list<SwFrameDeleteGuard> g;
#else
            ::boost::optional<SwFrameDeleteGuard> g;
            ::o3tl::optional<SwFrameDeleteGuard> g;
#endif
            if (m_rThis.GetUpper()->IsCellFrame())
            {
diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx
index 30b32d3..3fff3bc 100644
--- a/sw/source/core/layout/laycache.cxx
+++ b/sw/source/core/layout/laycache.cxx
@@ -652,7 +652,7 @@ bool SwLayHelper::CheckInsertPage()

    if ( bBrk || pDesc )
    {
        ::boost::optional<sal_uInt16> oPgNum;
        ::o3tl::optional<sal_uInt16> oPgNum;
        if ( !pDesc )
        {
            pDesc = mrpPage->GetPageDesc()->GetFollow();
diff --git a/sw/source/core/layout/newfrm.cxx b/sw/source/core/layout/newfrm.cxx
index 90bb478..90d4fbd 100644
--- a/sw/source/core/layout/newfrm.cxx
+++ b/sw/source/core/layout/newfrm.cxx
@@ -462,7 +462,7 @@ void SwRootFrame::Init( SwFrameFormat* pFormat )

    // Get hold of PageDesc (either via FrameFormat of the first node or the initial one).
    SwPageDesc *pDesc = nullptr;
    ::boost::optional<sal_uInt16> oPgNum;
    ::o3tl::optional<sal_uInt16> oPgNum;

    if ( pTableNd )
    {
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 6d1df44..c319115 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -1303,7 +1303,7 @@ SwPageFrame *SwFrame::InsertPage( SwPageFrame *pPrevPage, bool bFootnote )
        pDesc = rDesc.GetPageDesc();
        if ( rDesc.GetNumOffset() )
        {
            ::boost::optional<sal_uInt16> oNumOffset = rDesc.GetNumOffset();
            ::o3tl::optional<sal_uInt16> oNumOffset = rDesc.GetNumOffset();
            bWishedOdd = oNumOffset && (*oNumOffset % 2) != 0;
            // use the opportunity to set the flag at root
            pRoot->SetVirtPageNum( true );
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 21c6408..13d0fe0 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -4766,7 +4766,7 @@ namespace drawinglayer

namespace {

editeng::SvxBorderLine const * get_ptr(boost::optional<editeng::SvxBorderLine> const & opt) {
editeng::SvxBorderLine const * get_ptr(o3tl::optional<editeng::SvxBorderLine> const & opt) {
    return opt ? &*opt : nullptr;
}

diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx
index 7dc15c1..fe131db 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -1714,7 +1714,7 @@ bool SwFrame::WannaRightPage() const

    const SwFrame *pFlow = pPage->FindFirstBodyContent();
    const SwPageDesc *pDesc = nullptr;
    ::boost::optional<sal_uInt16> oPgNum;
    ::o3tl::optional<sal_uInt16> oPgNum;
    if ( pFlow )
    {
        if ( pFlow->IsInTab() )
@@ -1846,7 +1846,7 @@ sal_uInt16 SwFrame::GetVirtPageNum() const
    }
    if ( pFrame )
    {
        ::boost::optional<sal_uInt16> oNumOffset = pFrame->GetPageDescItem().GetNumOffset();
        ::o3tl::optional<sal_uInt16> oNumOffset = pFrame->GetPageDescItem().GetNumOffset();
        if (oNumOffset)
        {
            return nPhyPage - pFrame->GetPhyPageNum() + *oNumOffset;
diff --git a/sw/source/core/text/wrong.cxx b/sw/source/core/text/wrong.cxx
index 6865884..436214e 100644
--- a/sw/source/core/text/wrong.cxx
+++ b/sw/source/core/text/wrong.cxx
@@ -877,7 +877,7 @@ sal_uInt16 WrongListIteratorCounter::GetElementCount()
    return 0;
}

boost::optional<std::pair<TextFrameIndex, TextFrameIndex>>
o3tl::optional<std::pair<TextFrameIndex, TextFrameIndex>>
WrongListIteratorCounter::GetElementAt(sal_uInt16 nIndex)
{
    if (m_pMergedPara)
@@ -908,7 +908,7 @@ WrongListIteratorCounter::GetElementAt(sal_uInt16 nIndex)
                {
                    if (nIndex == 0)
                    {
                        return boost::optional<std::pair<TextFrameIndex, TextFrameIndex>>(
                        return o3tl::optional<std::pair<TextFrameIndex, TextFrameIndex>>(
                            std::pair<TextFrameIndex, TextFrameIndex>(
                                m_CurrentIndex - TextFrameIndex(rExtent.nStart -
                                    std::max(rExtent.nStart, pWrong->mnPos)),
@@ -921,17 +921,17 @@ WrongListIteratorCounter::GetElementAt(sal_uInt16 nIndex)
            m_CurrentIndex += TextFrameIndex(rExtent.nEnd - rExtent.nStart);
            ++m_CurrentExtent;
        }
        return boost::optional<std::pair<TextFrameIndex, TextFrameIndex>>();
        return o3tl::optional<std::pair<TextFrameIndex, TextFrameIndex>>();
    }
    else if (m_pWrongList)
    {
        SwWrongArea const*const pWrong(m_pWrongList->GetElement(nIndex));
        return boost::optional<std::pair<TextFrameIndex, TextFrameIndex>>(
        return o3tl::optional<std::pair<TextFrameIndex, TextFrameIndex>>(
            std::pair<TextFrameIndex, TextFrameIndex>(
                    TextFrameIndex(pWrong->mnPos),
                    TextFrameIndex(pWrong->mnPos + pWrong->mnLen)));
    }
    return boost::optional<std::pair<TextFrameIndex, TextFrameIndex>>();
    return o3tl::optional<std::pair<TextFrameIndex, TextFrameIndex>>();
}

} // namespace sw
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 9d698bf..f1df646 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -33,7 +33,7 @@
#include <functional>
#include <calbck.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>

@@ -820,7 +820,7 @@ lcl_SearchNextToken(const OUString & sPattern, sal_Int32 const nStt)

   @return the token
 */
static boost::optional<SwFormToken>
static o3tl::optional<SwFormToken>
lcl_BuildToken(const OUString & sPattern, sal_Int32 & nCurPatternPos)
{
    OUString sToken( lcl_SearchNextToken(sPattern, nCurPatternPos) );
@@ -830,7 +830,7 @@ lcl_BuildToken(const OUString & sPattern, sal_Int32 & nCurPatternPos)
    if (TOKEN_END == eTokenType) // invalid input? skip it
    {
        nCurPatternPos = sPattern.getLength();
        return boost::optional<SwFormToken>();
        return o3tl::optional<SwFormToken>();
    }

    // at this point sPattern contains the
@@ -909,7 +909,7 @@ SwFormTokensHelper::SwFormTokensHelper(const OUString & rPattern)

    while (nCurPatternPos < rPattern.getLength())
    {
        boost::optional<SwFormToken> const oToken(
        o3tl::optional<SwFormToken> const oToken(
                lcl_BuildToken(rPattern, nCurPatternPos));
        if (oToken)
            m_Tokens.push_back(*oToken);
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index 9816212..55284ce 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -124,7 +124,7 @@ void SwFont::SetLeftBorder( const editeng::SvxBorderLine* pLeftBorder )
    m_aSub[SwFontScript::Latin].m_nFontCacheId = m_aSub[SwFontScript::CJK].m_nFontCacheId = m_aSub[SwFontScript::CTL].m_nFontCacheId = nullptr;
}

const boost::optional<editeng::SvxBorderLine>&
const o3tl::optional<editeng::SvxBorderLine>&
SwFont::GetAbsTopBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
{
    switch (GetOrientation(bVertLayout, bVertLayoutLRBT))
@@ -148,7 +148,7 @@ SwFont::GetAbsTopBorder(const bool bVertLayout, const bool bVertLayoutLRBT) cons
    }
}

const boost::optional<editeng::SvxBorderLine>&
const o3tl::optional<editeng::SvxBorderLine>&
SwFont::GetAbsBottomBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
{
    switch (GetOrientation(bVertLayout, bVertLayoutLRBT))
@@ -172,7 +172,7 @@ SwFont::GetAbsBottomBorder(const bool bVertLayout, const bool bVertLayoutLRBT) c
    }
}

const boost::optional<editeng::SvxBorderLine>&
const o3tl::optional<editeng::SvxBorderLine>&
SwFont::GetAbsLeftBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
{
    switch (GetOrientation(bVertLayout, bVertLayoutLRBT))
@@ -196,7 +196,7 @@ SwFont::GetAbsLeftBorder(const bool bVertLayout, const bool bVertLayoutLRBT) con
    }
}

const boost::optional<editeng::SvxBorderLine>&
const o3tl::optional<editeng::SvxBorderLine>&
SwFont::GetAbsRightBorder(const bool bVertLayout, const bool bVertLayoutLRBT) const
{
    switch (GetOrientation(bVertLayout, bVertLayoutLRBT))
diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx
index 188ec6f..e0293d6 100644
--- a/sw/source/core/txtnode/txatbase.cxx
+++ b/sw/source/core/txtnode/txatbase.cxx
@@ -17,7 +17,7 @@
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <libxml/xmlwriter.h>
#include <svl/itempool.hxx>
#include <txatbase.hxx>
@@ -96,7 +96,7 @@ void SwTextAttr::dumpAsXml(xmlTextWriterPtr pWriter) const
        xmlTextWriterWriteAttribute(pWriter, BAD_CAST("end"), BAD_CAST(OString::number(*End()).getStr()));
    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
    const char* pWhich = nullptr;
    boost::optional<OString> oValue;
    o3tl::optional<OString> oValue;
    switch (Which())
    {
    case RES_TXTATR_AUTOFMT:
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index ab32dff..cf822f5 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -779,7 +779,7 @@ SwRewriter SwUndoDelete::GetRewriter() const
        }
        else
        {
            boost::optional<OUString> aTmpStr;
            o3tl::optional<OUString> aTmpStr;
            if (m_aSttStr)
                aTmpStr = m_aSttStr;
            else if (m_aEndStr)
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 4ebe984..3932194 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -61,9 +61,9 @@ using namespace ::com::sun::star;

// INSERT

boost::optional<OUString> SwUndoInsert::GetTextFromDoc() const
o3tl::optional<OUString> SwUndoInsert::GetTextFromDoc() const
{
    boost::optional<OUString> aResult;
    o3tl::optional<OUString> aResult;

    SwNodeIndex aNd( pDoc->GetNodes(), nNode);
    SwContentNode* pCNd = aNd.GetNode().GetContentNode();
@@ -454,7 +454,7 @@ void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext)
SwRewriter SwUndoInsert::GetRewriter() const
{
    SwRewriter aResult;
    boost::optional<OUString> aStr;
    o3tl::optional<OUString> aStr;
    bool bDone = false;

    if (maText)
@@ -800,8 +800,8 @@ void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext)

    // cache the old values
    std::unique_ptr<Graphic> pOldGrf( pGrf ? new Graphic(*pGrf) : nullptr);
    boost::optional<OUString> aOldNm = maNm;
    boost::optional<OUString> aOldFltr = maFltr;
    o3tl::optional<OUString> aOldNm = maNm;
    o3tl::optional<OUString> aOldFltr = maFltr;
    MirrorGraph nOldMirr = nMirr;
    // since all of them are cleared/modified by SaveGraphicData:
    SaveGraphicData( *pGrfNd );
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 72c3e20..0af9933 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -1090,7 +1090,7 @@ class HTMLEndPosLst

    SwDoc *pDoc;            // the current document
    SwDoc* const pTemplate;       // the HTML template (or 0)
    boost::optional<Color> xDfltColor;// the default foreground colors
    o3tl::optional<Color> xDfltColor;// the default foreground colors
    std::set<OUString>& rScriptTextStyles;

    sal_uLong const nHTMLMode;
@@ -1134,7 +1134,7 @@ class HTMLEndPosLst

public:

    HTMLEndPosLst( SwDoc *pDoc, SwDoc* pTemplate, boost::optional<Color> xDfltColor,
    HTMLEndPosLst( SwDoc *pDoc, SwDoc* pTemplate, o3tl::optional<Color> xDfltColor,
                   bool bOutStyles, sal_uLong nHTMLMode,
                   const OUString& rText, std::set<OUString>& rStyles );
    ~HTMLEndPosLst();
@@ -1582,7 +1582,7 @@ const SwHTMLFormatInfo *HTMLEndPosLst::GetFormatInfo( const SwFormat& rFormat,
    return pFormatInfo;
}

HTMLEndPosLst::HTMLEndPosLst(SwDoc* pD, SwDoc* pTempl, boost::optional<Color> xDfltCol,
HTMLEndPosLst::HTMLEndPosLst(SwDoc* pD, SwDoc* pTempl, o3tl::optional<Color> xDfltCol,
                             bool bStyles, sal_uLong nMode, const OUString& rText,
                             std::set<OUString>& rStyles)
    : pDoc(pD)
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 8056438..9743e70 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -296,7 +296,7 @@ public:
    css::uno::Reference<css::container::XIndexContainer> mxFormComps; // current form

    rtl::Reference<SwDoc> m_xTemplate;               // HTML template
    boost::optional<Color> m_xDfltColor;              // default colour
    o3tl::optional<Color> m_xDfltColor;              // default colour
    SwNodeIndex *m_pStartNdIdx;       // index of first paragraph
    const SwPageDesc *m_pCurrPageDesc;// current page style
    const SwFormatFootnote *m_pFormatFootnote;
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 70509ed..dfcbd91 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -27,7 +27,7 @@
#include <rtl/textenc.h>
#include <editeng/svxenum.hxx>
#include <tools/solar.h>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <swtypes.hxx>
@@ -339,7 +339,7 @@ public:

    /// The style of the page numbers.
    ///
    virtual void SectionPageNumbering( sal_uInt16 nNumType, const ::boost::optional<sal_uInt16>& oPageRestartNumber ) = 0;
    virtual void SectionPageNumbering( sal_uInt16 nNumType, const ::o3tl::optional<sal_uInt16>& oPageRestartNumber ) = 0;

    /// The type of breaking.
    virtual void SectionType( sal_uInt8 nBreakCode ) = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 113d261..91d77e8 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2486,7 +2486,7 @@ const NameToId constNameToIdMapping[] =
    { OUString("styleSet"),     FSNS( XML_w14, XML_styleSet ) },
};

boost::optional<sal_Int32> lclGetElementIdForName(const OUString& rName)
o3tl::optional<sal_Int32> lclGetElementIdForName(const OUString& rName)
{
    for (auto const & i : constNameToIdMapping)
    {
@@ -2495,7 +2495,7 @@ boost::optional<sal_Int32> lclGetElementIdForName(const OUString& rName)
            return i.maId;
        }
    }
    return boost::optional<sal_Int32>();
    return o3tl::optional<sal_Int32>();
}

void lclProcessRecursiveGrabBag(sal_Int32 aElementId, const css::uno::Sequence<css::beans::PropertyValue>& rElements, sax_fastparser::FSHelperPtr const & pSerializer)
@@ -2525,7 +2525,7 @@ void lclProcessRecursiveGrabBag(sal_Int32 aElementId, const css::uno::Sequence<c
            aValue =  OUStringToOString(aAny.get<OUString>(), RTL_TEXTENCODING_ASCII_US);
        }

        boost::optional<sal_Int32> aSubElementId = lclGetElementIdForName(rAttribute.Name);
        o3tl::optional<sal_Int32> aSubElementId = lclGetElementIdForName(rAttribute.Name);
        if(aSubElementId)
            pAttributes->add(*aSubElementId, aValue.getStr());
    }
@@ -2538,7 +2538,7 @@ void lclProcessRecursiveGrabBag(sal_Int32 aElementId, const css::uno::Sequence<c
    {
        css::uno::Sequence<css::beans::PropertyValue> aSumElements;

        boost::optional<sal_Int32> aSubElementId = lclGetElementIdForName(rElement.Name);
        o3tl::optional<sal_Int32> aSubElementId = lclGetElementIdForName(rElement.Name);
        if(aSubElementId)
        {
            rElement.Value >>= aSumElements;
@@ -2585,7 +2585,7 @@ void DocxAttributeOutput::WriteCollectedRunProperties()

    for (const beans::PropertyValue & i : m_aTextEffectsGrabBag)
    {
        boost::optional<sal_Int32> aElementId = lclGetElementIdForName(i.Name);
        o3tl::optional<sal_Int32> aElementId = lclGetElementIdForName(i.Name);
        if(aElementId)
        {
            uno::Sequence<beans::PropertyValue> aGrabBagSeq;
@@ -6320,13 +6320,13 @@ static OString impl_LevelNFC( sal_uInt16 nNumberingType , const SfxItemSet *pOut
}


void DocxAttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, const ::boost::optional<sal_uInt16>& oPageRestartNumber )
void DocxAttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, const ::o3tl::optional<sal_uInt16>& oPageRestartNumber )
{
    // FIXME Not called properly with page styles like "First Page"

    FastAttributeList* pAttr = FastSerializerHelper::createAttrList();

    // boost::none means no restart: then don't output that attribute if it is negative
    // o3tl::nullopt means no restart: then don't output that attribute if it is negative
    if ( oPageRestartNumber )
       pAttr->add( FSNS( XML_w, XML_start ), OString::number( *oPageRestartNumber ) );

@@ -8285,9 +8285,9 @@ void DocxAttributeOutput::FormatAnchor( const SwFormatAnchor& )
    // Fly frames: anchors here aren't matching the anchors in docx
}

static boost::optional<sal_Int32> lcl_getDmlAlpha(const SvxBrushItem& rBrush)
static o3tl::optional<sal_Int32> lcl_getDmlAlpha(const SvxBrushItem& rBrush)
{
    boost::optional<sal_Int32> oRet;
    o3tl::optional<sal_Int32> oRet;
    sal_Int32 nTransparency = rBrush.GetColor().GetTransparency();
    if (nTransparency)
    {
@@ -8306,7 +8306,7 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
{
    const Color aColor = rBrush.GetColor();
    OString sColor = msfilter::util::ConvertColor( aColor.GetRGBColor() );
    boost::optional<sal_Int32> oAlpha = lcl_getDmlAlpha(rBrush);
    o3tl::optional<sal_Int32> oAlpha = lcl_getDmlAlpha(rBrush);
    if (m_rExport.SdrExporter().getTextFrameSyntax())
    {
        // Handle 'Opacity'
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 6756108..7f3f0e6 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -37,7 +37,7 @@
#include <fldbas.hxx>

#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <oox/export/vmlexport.hxx>
#include <oox/export/drawingml.hxx>
#include "docxtablestyleexport.hxx"
@@ -299,7 +299,7 @@ public:

    /// The style of the page numbers.
    ///
    virtual void SectionPageNumbering( sal_uInt16 nNumType, const ::boost::optional<sal_uInt16>& oPageRestartNumber ) override;
    virtual void SectionPageNumbering( sal_uInt16 nNumType, const ::o3tl::optional<sal_uInt16>& oPageRestartNumber ) override;

    /// The type of breaking.
    virtual void SectionType( sal_uInt8 nBreakCode ) override;
@@ -932,7 +932,7 @@ private:
    std::vector<sal_Int32> lastOpenCell;
    std::vector<sal_Int32> lastClosedCell;

    boost::optional<css::drawing::FillStyle> m_oFillStyle;
    o3tl::optional<css::drawing::FillStyle> m_oFillStyle;
    /// If FormatBox() already handled fill style / gradient.
    bool m_bIgnoreNextFill;

diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx
index 6ffa143..487ec6b 100644
--- a/sw/source/filter/ww8/docxtablestyleexport.cxx
+++ b/sw/source/filter/ww8/docxtablestyleexport.cxx
@@ -15,7 +15,7 @@
#include <comphelper/sequenceashashmap.hxx>
#include <sax/fastattribs.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
@@ -525,8 +525,8 @@ void DocxTableStyleExport::Impl::tableStyleTablePr(
    uno::Sequence<beans::PropertyValue> aTableInd;
    uno::Sequence<beans::PropertyValue> aTableBorders;
    uno::Sequence<beans::PropertyValue> aTableCellMar;
    boost::optional<sal_Int32> oTableStyleRowBandSize;
    boost::optional<sal_Int32> oTableStyleColBandSize;
    o3tl::optional<sal_Int32> oTableStyleRowBandSize;
    o3tl::optional<sal_Int32> oTableStyleColBandSize;
    for (const auto& rProp : rTablePr)
    {
        if (rProp.Name == "tblStyleRowBandSize")
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 8306c20..749613f 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -1292,7 +1292,7 @@ void RtfAttributeOutput::SectionBiDi(bool bBiDi)
}

void RtfAttributeOutput::SectionPageNumbering(
    sal_uInt16 nNumType, const ::boost::optional<sal_uInt16>& oPageRestartNumber)
    sal_uInt16 nNumType, const ::o3tl::optional<sal_uInt16>& oPageRestartNumber)
{
    if (oPageRestartNumber)
    {
@@ -3214,7 +3214,7 @@ void RtfAttributeOutput::FormatSurround(const SwFormatSurround& rSurround)
    {
        // See DocxSdrExport::startDMLAnchorInline() for SwFormatSurround -> WR / WRK mappings.
        sal_Int32 nWr = -1;
        boost::optional<sal_Int32> oWrk;
        o3tl::optional<sal_Int32> oWrk;
        switch (rSurround.GetValue())
        {
            case css::text::WrapTextMode_NONE:
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index 4ea8b38..3003ec5 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -30,7 +30,7 @@

#include <rtl/strbuf.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class SwGrfNode;
class SwOLENode;
@@ -193,7 +193,7 @@ public:
    /// The style of the page numbers.
    ///
    void SectionPageNumbering(sal_uInt16 nNumType,
                              const ::boost::optional<sal_uInt16>& oPageRestartNumber) override;
                              const ::o3tl::optional<sal_uInt16>& oPageRestartNumber) override;

    /// The type of breaking.
    void SectionType(sal_uInt8 nBreakCode) override;
@@ -610,7 +610,7 @@ private:

    std::vector<std::pair<OString, OString>> m_aFlyProperties;

    boost::optional<css::drawing::FillStyle> m_oFillStyle;
    o3tl::optional<css::drawing::FillStyle> m_oFillStyle;

    /// If we're in the process of exporting a hyperlink, then its URL.
    OUString m_sURL;
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index db27ad4..6961722 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -1385,7 +1385,7 @@ void RtfExport::OutPageDescription(const SwPageDesc& rPgDsc, bool bCheckForFirst

    // numbering type
    AttrOutput().SectionPageNumbering(m_pCurrentPageDesc->GetNumType().GetNumberingType(),
                                      boost::none);
                                      o3tl::nullopt);

    m_pCurrentPageDesc = pSave;
    SAL_INFO("sw.rtf", OSL_THIS_FUNC << " end");
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index ed4f15c..6226270 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1101,7 +1101,7 @@ void MSWordSections::AppendSection( const SwPageDesc* pPd,
    if (HeaderFooterWritten()) {
        return; // #i117955# prevent new sections in endnotes
    }
    aSects.emplace_back( pPd, pSectionFormat, nLnNumRestartNo, boost::none, nullptr, bIsFirstParagraph );
    aSects.emplace_back( pPd, pSectionFormat, nLnNumRestartNo, o3tl::nullopt, nullptr, bIsFirstParagraph );
    NeedsDocumentProtected( aSects.back() );
}

@@ -1422,7 +1422,7 @@ void WW8AttributeOutput::SectionBiDi( bool bBiDi )
    m_rWW8Export.pO->push_back( bBiDi? 1: 0 );
}

void WW8AttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, const ::boost::optional<sal_uInt16>& oPageRestartNumber )
void WW8AttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, const ::o3tl::optional<sal_uInt16>& oPageRestartNumber )
{
    // sprmSNfcPgn
    sal_uInt8 nb = WW8Export::GetNumId( nNumType );
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 9824f52..44bf187 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -38,7 +38,7 @@

#include <vcl/graph.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <o3tl/typed_flags_set.hxx>

#include <cstddef>
@@ -179,11 +179,11 @@ struct WW8_SepInfo
    const SwSectionFormat* pSectionFormat;
    const SwNode* pPDNd;
    sal_uLong const  nLnNumRestartNo;
    ::boost::optional<sal_uInt16> const oPgRestartNo;
    ::o3tl::optional<sal_uInt16> const oPgRestartNo;
    bool const bIsFirstParagraph;

    WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFormat* pFormat,
                 sal_uLong nLnRestart, ::boost::optional<sal_uInt16> oPgRestart = boost::none,
                 sal_uLong nLnRestart, ::o3tl::optional<sal_uInt16> oPgRestart = o3tl::nullopt,
                 const SwNode* pNd = nullptr, bool bIsFirstPara = false )
        : pPageDesc( pPD ), pSectionFormat( pFormat ), pPDNd( pNd ),
          nLnNumRestartNo( nLnRestart ), oPgRestartNo( oPgRestart ),
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 7e3f2a3..ead3236 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -180,7 +180,7 @@ public:

    /// The style of the page numbers.
    ///
    virtual void SectionPageNumbering( sal_uInt16 nNumType, const ::boost::optional<sal_uInt16>& oPageRestartNumber ) override;
    virtual void SectionPageNumbering( sal_uInt16 nNumType, const ::o3tl::optional<sal_uInt16>& oPageRestartNumber ) override;

    /// The type of breaking.
    virtual void SectionType( sal_uInt8 nBreakCode ) override;
diff --git a/sw/source/filter/xml/xmlexpit.cxx b/sw/source/filter/xml/xmlexpit.cxx
index ef7ce5b..bab3f52 100644
--- a/sw/source/filter/xml/xmlexpit.cxx
+++ b/sw/source/filter/xml/xmlexpit.cxx
@@ -986,7 +986,7 @@ bool SvXMLExportItemMapper::QueryXMLValue(

            if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId )
            {
                ::boost::optional<sal_uInt16> oNumOffset = rPageDesc.GetNumOffset();
                ::o3tl::optional<sal_uInt16> oNumOffset = rPageDesc.GetNumOffset();
                if (oNumOffset && *oNumOffset > 0)
                {
                    // #i114163# positiveInteger only!
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index 05dccd0..0150ee3 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -379,7 +379,7 @@ sal_uInt16 AbstractSwBreakDlg_Impl:: GetKind()
    return m_xDlg->GetKind();
}

::boost::optional<sal_uInt16> AbstractSwBreakDlg_Impl:: GetPageNumber()
::o3tl::optional<sal_uInt16> AbstractSwBreakDlg_Impl:: GetPageNumber()
{
    return m_xDlg->GetPageNumber();
}
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 579fe94..c0e1aee 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -75,7 +75,7 @@ class SwTOXMark;
class SwSplitTableDlg;

#include <itabenum.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <o3tl/deleter.hxx>

namespace sw
@@ -183,7 +183,7 @@ public:
    virtual short Execute() override;
    virtual OUString                        GetTemplateName() override;
    virtual sal_uInt16                      GetKind() override;
    virtual ::boost::optional<sal_uInt16>   GetPageNumber() override;
    virtual ::o3tl::optional<sal_uInt16>   GetPageNumber() override;
};

class AbstractSwTableWidthDlg_Impl : public VclAbstractDialog
diff --git a/sw/source/ui/misc/titlepage.cxx b/sw/source/ui/misc/titlepage.cxx
index b000026..2e4279d 100644
--- a/sw/source/ui/misc/titlepage.cxx
+++ b/sw/source/ui/misc/titlepage.cxx
@@ -37,7 +37,7 @@ namespace
            const SfxPoolItem* pItem(nullptr);
            if (SfxItemState::SET == aSet.GetItemState( RES_PAGEDESC, true, &pItem ) && pItem)
            {
                ::boost::optional<sal_uInt16> oNumOffset = static_cast<const SwFormatPageDesc *>(pItem)->GetNumOffset();
                ::o3tl::optional<sal_uInt16> oNumOffset = static_cast<const SwFormatPageDesc *>(pItem)->GetNumOffset();
                if (oNumOffset)
                    rPageNo = *oNumOffset;
                if (ppPageFormatDesc)
@@ -68,7 +68,7 @@ namespace
        {
            if (pPageFormatDesc)
            {
                ::boost::optional<sal_uInt16> oNumOffset = pPageFormatDesc->GetNumOffset();
                ::o3tl::optional<sal_uInt16> oNumOffset = pPageFormatDesc->GetNumOffset();
                if (oNumOffset)
                {
                    nPgNo = *oNumOffset;
diff --git a/sw/source/ui/table/tabledlg.cxx b/sw/source/ui/table/tabledlg.cxx
index 51ccdfb..821eb68 100644
--- a/sw/source/ui/table/tabledlg.cxx
+++ b/sw/source/ui/table/tabledlg.cxx
@@ -1326,8 +1326,8 @@ bool  SwTextFlowPage::FillItemSet( SfxItemSet* rSet )
        }
        sal_uInt16 nPgNum = static_cast<sal_uInt16>(m_xPageNoNF->get_value());
        bool const usePageNo(bState && m_xPageNoCB->get_active());
        boost::optional<sal_uInt16> const oPageNum(
                usePageNo ? nPgNum : boost::optional<sal_Int16>());
        o3tl::optional<sal_uInt16> const oPageNum(
                usePageNo ? nPgNum : o3tl::optional<sal_Int16>());
        if (!pDesc || !pDesc->GetPageDesc()
            || (pDesc->GetPageDesc()->GetName() != sPage)
            || (pDesc->GetNumOffset() != oPageNum))
@@ -1454,7 +1454,7 @@ void   SwTextFlowPage::Reset( const SfxItemSet* rSet )
                OUString sPageDesc;
                const SwPageDesc* pDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc();

                ::boost::optional<sal_uInt16> oNumOffset = static_cast<const SwFormatPageDesc*>(pItem)->GetNumOffset();
                ::o3tl::optional<sal_uInt16> oNumOffset = static_cast<const SwFormatPageDesc*>(pItem)->GetNumOffset();
                if (oNumOffset)
                {
                    m_xPageNoCB->set_active(true);
diff --git a/sw/source/uibase/app/appenv.cxx b/sw/source/uibase/app/appenv.cxx
index 1bcd43c..23eb98f 100644
--- a/sw/source/uibase/app/appenv.cxx
+++ b/sw/source/uibase/app/appenv.cxx
@@ -301,7 +301,7 @@ void SwModule::InsertEnv( SfxRequest& rReq )
            else
            {
                OUString sFollowName(pFollow->GetName());
                pSh->InsertPageBreak(&sFollowName, boost::none);
                pSh->InsertPageBreak(&sFollowName, o3tl::nullopt);
            }
            pSh->SttEndDoc(true);
        }
diff --git a/sw/source/uibase/docvw/PageBreakWin.cxx b/sw/source/uibase/docvw/PageBreakWin.cxx
index e50dcbb..a23ef76 100644
--- a/sw/source/uibase/docvw/PageBreakWin.cxx
+++ b/sw/source/uibase/docvw/PageBreakWin.cxx
@@ -329,7 +329,7 @@ void SwPageBreakWin::Activate( )
    MenuButton::Activate();
}

void SwPageBreakWin::UpdatePosition(const boost::optional<Point>& xEvtPt)
void SwPageBreakWin::UpdatePosition(const o3tl::optional<Point>& xEvtPt)
{
    if ( xEvtPt )
    {
diff --git a/sw/source/uibase/inc/PageBreakWin.hxx b/sw/source/uibase/inc/PageBreakWin.hxx
index 9b07dd3..3950061 100644
--- a/sw/source/uibase/inc/PageBreakWin.hxx
+++ b/sw/source/uibase/inc/PageBreakWin.hxx
@@ -13,7 +13,7 @@
#include "FrameControl.hxx"
#include <vcl/builder.hxx>
#include <vcl/timer.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class Menu;
class SwPageFrame;
@@ -34,7 +34,7 @@ class SwPageBreakWin : public SwFrameMenuButtonBase
    Timer                 m_aFadeTimer;
    bool                  m_bDestroyed;

    boost::optional<Point> m_xMousePt;
    o3tl::optional<Point> m_xMousePt;

public:
    SwPageBreakWin( SwEditWin* pEditWin, const SwFrame *pFrame );
@@ -46,7 +46,7 @@ public:
    virtual void MouseMove( const MouseEvent& rMEvt ) override;
    virtual void Activate( ) override;

    void UpdatePosition(const boost::optional<Point>& xEvtPt = boost::optional<Point>());
    void UpdatePosition(const o3tl::optional<Point>& xEvtPt = o3tl::optional<Point>());

    virtual void ShowAll( bool bShow ) override;
    virtual bool Contains( const Point &rDocPt ) const override;
diff --git a/sw/source/uibase/inc/break.hxx b/sw/source/uibase/inc/break.hxx
index 65d129f..18c5069 100644
--- a/sw/source/uibase/inc/break.hxx
+++ b/sw/source/uibase/inc/break.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_SW_SOURCE_UIBASE_INC_BREAK_HXX

#include <vcl/weld.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class SwWrtShell;

@@ -39,7 +39,7 @@ class SwBreakDlg : public weld::GenericDialogController
    SwWrtShell     &rSh;
    OUString        m_aTemplate;
    sal_uInt16      nKind;
    ::boost::optional<sal_uInt16>      oPgNum;
    ::o3tl::optional<sal_uInt16>      oPgNum;

    bool const            bHtmlMode;

@@ -56,7 +56,7 @@ public:
    virtual short run() override;
    const OUString& GetTemplateName() const { return m_aTemplate; }
    sal_uInt16 GetKind() const { return nKind; }
    const ::boost::optional<sal_uInt16>&  GetPageNumber() const { return oPgNum; }
    const ::o3tl::optional<sal_uInt16>&  GetPageNumber() const { return oPgNum; }
};

#endif
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index fb9f9f7..acd463a 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -92,7 +92,7 @@ class SW_DLLPUBLIC SwEditWin final : public vcl::Window,
    std::unique_ptr<SdrDropMarkerOverlay> m_pUserMarker;
    SdrObject               *m_pUserMarkerObj;
    std::unique_ptr<SwShadowCursor, o3tl::default_delete<SwShadowCursor>> m_pShadCursor;
    boost::optional<Point>                m_xRowColumnSelectionStart; // save position where table row/column selection has been started
    o3tl::optional<Point>                m_xRowColumnSelectionStart; // save position where table row/column selection has been started

    SwView         &m_rView;

diff --git a/sw/source/uibase/inc/toxmgr.hxx b/sw/source/uibase/inc/toxmgr.hxx
index 0fde183f..e9a49e7 100644
--- a/sw/source/uibase/inc/toxmgr.hxx
+++ b/sw/source/uibase/inc/toxmgr.hxx
@@ -24,7 +24,7 @@
#include <tox.hxx>
#include <authfld.hxx>
#include <memory>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class SwWrtShell;
class SwForm;
@@ -38,9 +38,9 @@ class SW_DLLPUBLIC SwTOXDescription
    OUString            m_sSequenceName;
    OUString            m_sMainEntryCharStyle;
    OUString            m_sAutoMarkURL;
    boost::optional<OUString>
    o3tl::optional<OUString>
                        m_aTitle;
    boost::optional<OUString>
    o3tl::optional<OUString>
                        m_aTOUName;
    std::unique_ptr<SwForm>
                        m_pForm;
@@ -98,10 +98,10 @@ public:
    void            SetAutoMarkURL(const OUString& rSet) {m_sAutoMarkURL = rSet;}

    void            SetTitle(const OUString& rSet) { m_aTitle = rSet; }
    boost::optional<OUString> const & GetTitle() const {return m_aTitle; }
    o3tl::optional<OUString> const & GetTitle() const {return m_aTitle; }

    void            SetTOUName(const OUString& rSet) { m_aTOUName = rSet; }
    boost::optional<OUString> const & GetTOUName() const { return m_aTOUName; }
    o3tl::optional<OUString> const & GetTOUName() const { return m_aTOUName; }

    void            SetForm(const SwForm& rSet) { m_pForm.reset( new SwForm(rSet) );}
    const SwForm*   GetForm() const {return m_pForm.get();}
@@ -172,14 +172,14 @@ class SwTOXMarkDescription
    int         mnLevel;
    bool        mbMainEntry;

    boost::optional<OUString>  maPrimKey;
    boost::optional<OUString>  maSecKey;
    boost::optional<OUString>  maAltStr;
    boost::optional<OUString>  maTOUName;
    o3tl::optional<OUString>  maPrimKey;
    o3tl::optional<OUString>  maSecKey;
    o3tl::optional<OUString>  maAltStr;
    o3tl::optional<OUString>  maTOUName;

    boost::optional<OUString>  maPhoneticReadingOfAltStr;
    boost::optional<OUString>  maPhoneticReadingOfPrimKey;
    boost::optional<OUString>  maPhoneticReadingOfSecKey;
    o3tl::optional<OUString>  maPhoneticReadingOfAltStr;
    o3tl::optional<OUString>  maPhoneticReadingOfPrimKey;
    o3tl::optional<OUString>  maPhoneticReadingOfSecKey;

    SwTOXMarkDescription(SwTOXMarkDescription const &) = delete;
    SwTOXMarkDescription & operator= (SwTOXMarkDescription const &) = delete;
@@ -202,25 +202,25 @@ public:
    bool            IsMainEntry() const {return mbMainEntry;}

    void            SetPrimKey(const OUString& rSet) { maPrimKey = rSet; }
    boost::optional<OUString> const & GetPrimKey() const { return maPrimKey; }
    o3tl::optional<OUString> const & GetPrimKey() const { return maPrimKey; }

    void            SetSecKey(const OUString& rSet) { maSecKey = rSet; }
    boost::optional<OUString> const & GetSecKey() const { return maSecKey; }
    o3tl::optional<OUString> const & GetSecKey() const { return maSecKey; }

    void            SetAltStr(const OUString& rSet) { maAltStr = rSet; }
    boost::optional<OUString> const & GetAltStr() const { return maAltStr; }
    o3tl::optional<OUString> const & GetAltStr() const { return maAltStr; }

    void            SetTOUName(const OUString& rSet) { maTOUName = rSet; }
    boost::optional<OUString> const & GetTOUName() const { return maTOUName; }
    o3tl::optional<OUString> const & GetTOUName() const { return maTOUName; }

    void            SetPhoneticReadingOfAltStr(const OUString& rSet) { maPhoneticReadingOfAltStr = rSet; }
    boost::optional<OUString> const & GetPhoneticReadingOfAltStr() const { return maPhoneticReadingOfAltStr; }
    o3tl::optional<OUString> const & GetPhoneticReadingOfAltStr() const { return maPhoneticReadingOfAltStr; }

    void            SetPhoneticReadingOfPrimKey(const OUString& rSet) { maPhoneticReadingOfPrimKey = rSet; }
    boost::optional<OUString> const & GetPhoneticReadingOfPrimKey() const { return maPhoneticReadingOfPrimKey; }
    o3tl::optional<OUString> const & GetPhoneticReadingOfPrimKey() const { return maPhoneticReadingOfPrimKey; }

    void            SetPhoneticReadingOfSecKey(const OUString& rSet) { maPhoneticReadingOfSecKey = rSet; }
    boost::optional<OUString> const & GetPhoneticReadingOfSecKey() const { return maPhoneticReadingOfSecKey; }
    o3tl::optional<OUString> const & GetPhoneticReadingOfSecKey() const { return maPhoneticReadingOfSecKey; }
};

class SW_DLLPUBLIC SwTOXMgr
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index 6ec17d5b..61c4389 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -24,7 +24,7 @@
#include <swurl.hxx>
#include <IMark.hxx>
#include "navmgr.hxx"
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <svx/swframetypes.hxx>
#include <vcl/weld.hxx>
@@ -308,7 +308,7 @@ typedef bool (SwWrtShell:: *FNSimpleMove)();
                    RndStdIds nAnchorType = RndStdIds::FLY_AT_PARA);

    void    InsertByWord( const OUString & );
    void    InsertPageBreak(const OUString *pPageDesc = nullptr, const ::boost::optional<sal_uInt16>& rPgNum = boost::none);
    void    InsertPageBreak(const OUString *pPageDesc = nullptr, const ::o3tl::optional<sal_uInt16>& rPgNum = o3tl::nullopt);
    void    InsertLineBreak();
    void    InsertColumnBreak();
    void    InsertFootnote(const OUString &, bool bEndNote = false, bool bEdit = true );
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index d6857e8..dce1531 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -627,7 +627,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
        case FN_INSERT_BREAK_DLG:
        {
            sal_uInt16 nKind=0;
            ::boost::optional<sal_uInt16> oPageNumber;
            ::o3tl::optional<sal_uInt16> oPageNumber;
            OUString aTemplateName;
            if ( pItem )
            {
diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx
index 2e97300..a1c95c2 100644
--- a/sw/source/uibase/uiview/viewsrch.cxx
+++ b/sw/source/uibase/uiview/viewsrch.cxx
@@ -310,7 +310,7 @@ void SwView::ExecSearch(SfxRequest& rReq)
                            m_pWrtShell->Push();
                        OUString aReplace( s_pSrchItem->GetReplaceString() );
                        i18nutil::SearchOptions2 aTmp( s_pSrchItem->GetSearchOptions() );
                        boost::optional<OUString> xBackRef = sw::ReplaceBackReferences(aTmp,
                        o3tl::optional<OUString> xBackRef = sw::ReplaceBackReferences(aTmp,
                            m_pWrtShell->GetCursor(), m_pWrtShell->GetLayout());
                        if( xBackRef )
                            s_pSrchItem->SetReplaceString( *xBackRef );
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index 9e8434e..f5dfd21 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -671,7 +671,7 @@ void SwToSfxPageDescAttr( SfxItemSet& rCoreSet )
{
    const SfxPoolItem* pItem = nullptr;
    OUString aName;
    ::boost::optional<sal_uInt16> oNumOffset;
    ::o3tl::optional<sal_uInt16> oNumOffset;
    bool bPut = true;
    switch( rCoreSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
    {
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 9eb00d36..432a578 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -885,7 +885,7 @@ void SwWrtShell::ConnectObj( svt::EmbeddedObjectRef& xObj, const SwRect &rPrt,

// Insert hard page break;
// Selections will be overwritten
void SwWrtShell::InsertPageBreak(const OUString *pPageDesc, const ::boost::optional<sal_uInt16>& oPgNum )
void SwWrtShell::InsertPageBreak(const OUString *pPageDesc, const ::o3tl::optional<sal_uInt16>& oPgNum )
{
    ResetCursorStack();
    if( CanInsert() )
diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx
index d6d4d77..554f08f 100644
--- a/toolkit/source/controls/unocontrols.cxx
+++ b/toolkit/source/controls/unocontrols.cxx
@@ -2264,7 +2264,7 @@ void SAL_CALL UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition, c
    ListItem& rItem( m_xData->insertItem( i_nPosition ) );
    rItem.ItemText = i_rItemText;

    impl_handleInsert( i_nPosition, i_rItemText, ::boost::optional< OUString >(), aGuard );
    impl_handleInsert( i_nPosition, i_rItemText, ::o3tl::optional< OUString >(), aGuard );
    // <----- SYNCHRONIZED
}

@@ -2276,7 +2276,7 @@ void SAL_CALL UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition, 
    ListItem& rItem( m_xData->insertItem( i_nPosition ) );
    rItem.ItemImageURL = i_rItemImageURL;

    impl_handleInsert( i_nPosition, ::boost::optional< OUString >(), i_rItemImageURL, aGuard );
    impl_handleInsert( i_nPosition, ::o3tl::optional< OUString >(), i_rItemImageURL, aGuard );
    // <----- SYNCHRONIZED
}

@@ -2310,7 +2310,7 @@ void SAL_CALL UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition, cons
    ListItem& rItem( m_xData->getItem( i_nPosition ) );
    rItem.ItemText = i_rItemText;

    impl_handleModify( i_nPosition, i_rItemText, ::boost::optional< OUString >(), aGuard );
    impl_handleModify( i_nPosition, i_rItemText, ::o3tl::optional< OUString >(), aGuard );
    // <----- SYNCHRONIZED
}

@@ -2322,7 +2322,7 @@ void SAL_CALL UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition, con
    ListItem& rItem( m_xData->getItem( i_nPosition ) );
    rItem.ItemImageURL = i_rItemImageURL;

    impl_handleModify( i_nPosition, ::boost::optional< OUString >(), i_rItemImageURL, aGuard );
    impl_handleModify( i_nPosition, ::o3tl::optional< OUString >(), i_rItemImageURL, aGuard );
    // <----- SYNCHRONIZED
}

@@ -2429,8 +2429,8 @@ void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector< 
}


void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition, const ::boost::optional< OUString >& i_rItemText,
        const ::boost::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition, const ::o3tl::optional< OUString >& i_rItemText,
        const ::o3tl::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
{
    // SYNCHRONIZED ----->
    // sync with legacy StringItemList property
@@ -2484,14 +2484,14 @@ void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition,
    }
    else
    {
        impl_notifyItemListEvent_nolck( i_nItemPosition, ::boost::optional< OUString >(), ::boost::optional< OUString >(),
        impl_notifyItemListEvent_nolck( i_nItemPosition, ::o3tl::optional< OUString >(), ::o3tl::optional< OUString >(),
            &XItemListListener::listItemRemoved );
    }
}


void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition, const ::boost::optional< OUString >& i_rItemText,
        const ::boost::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition, const ::o3tl::optional< OUString >& i_rItemText,
        const ::o3tl::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
{
    // SYNCHRONIZED ----->
    if ( !!i_rItemText )
@@ -2520,8 +2520,8 @@ void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition,
}


void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition, const ::boost::optional< OUString >& i_rItemText,
    const ::boost::optional< OUString >& i_rItemImageURL,
void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition, const ::o3tl::optional< OUString >& i_rItemText,
    const ::o3tl::optional< OUString >& i_rItemImageURL,
    void ( SAL_CALL XItemListListener::*NotificationMethod )( const ItemListEvent& ) )
{
    ItemListEvent aEvent;
diff --git a/ucb/source/ucp/ext/ucpext_content.hxx b/ucb/source/ucp/ext/ucpext_content.hxx
index 0bfc2a4..ebe17b3 100644
--- a/ucb/source/ucp/ext/ucpext_content.hxx
+++ b/ucb/source/ucp/ext/ucpext_content.hxx
@@ -25,7 +25,7 @@

#include <ucbhelper/contenthelper.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>


namespace ucb { namespace ucp { namespace ext
@@ -122,8 +122,8 @@ namespace ucb { namespace ucp { namespace ext

    private:
        ExtensionContentType                    m_eExtContentType;
        ::boost::optional< bool >               m_aIsFolder;
        ::boost::optional< OUString >    m_aContentType;
        ::o3tl::optional< bool >               m_aIsFolder;
        ::o3tl::optional< OUString >    m_aContentType;
        OUString                         m_sExtensionId;
        OUString                         m_sPathIntoExtension;
    };
diff --git a/unotools/inc/pch/precompiled_utl.hxx b/unotools/inc/pch/precompiled_utl.hxx
index ddffb52..7a2b9b8 100644
--- a/unotools/inc/pch/precompiled_utl.hxx
+++ b/unotools/inc/pch/precompiled_utl.hxx
@@ -32,7 +32,7 @@
#include <vector>
#include <boost/locale.hpp>
#include <boost/locale/gnu_gettext.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/detail/file.h>
diff --git a/unotools/source/config/historyoptions.cxx b/unotools/source/config/historyoptions.cxx
index 1647313..e65a2a9 100644
--- a/unotools/source/config/historyoptions.cxx
+++ b/unotools/source/config/historyoptions.cxx
@@ -34,7 +34,7 @@
#include <comphelper/configurationhelper.hxx>
#include <comphelper/processfactory.hxx>
#include <tools/diagnose_ex.h>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

using namespace ::std;
using namespace ::utl;
@@ -78,7 +78,7 @@ public:

    void AppendItem(EHistoryType eHistory,
        const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
        const boost::optional<OUString>& sThumbnail);
        const o3tl::optional<OUString>& sThumbnail);

    void DeleteItem(EHistoryType eHistory, const OUString& sURL);

@@ -317,7 +317,7 @@ Sequence< Sequence<PropertyValue> > SvtHistoryOptions_Impl::GetList(EHistoryType

void SvtHistoryOptions_Impl::AppendItem(EHistoryType eHistory,
        const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
        const boost::optional<OUString>& sThumbnail)
        const o3tl::optional<OUString>& sThumbnail)
{
    uno::Reference<container::XNameAccess> xListAccess(GetListAccess(eHistory));
    if (!xListAccess.is())
@@ -551,7 +551,7 @@ Sequence< Sequence< PropertyValue > > SvtHistoryOptions::GetList( EHistoryType e

void SvtHistoryOptions::AppendItem(EHistoryType eHistory,
        const OUString& sURL, const OUString& sFilter, const OUString& sTitle,
        const boost::optional<OUString>& sThumbnail)
        const o3tl::optional<OUString>& sThumbnail)
{
    MutexGuard aGuard(theHistoryOptionsMutex::get());

diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx
index 5e679b7..46bcdfa 100644
--- a/unoxml/source/rdf/librdf_repository.cxx
+++ b/unoxml/source/rdf/librdf_repository.cxx
@@ -28,7 +28,7 @@
#include <algorithm>
#include <atomic>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <libxslt/security.h>

@@ -201,9 +201,9 @@ public:
    {
        OString const value;
        OString const language;
        ::boost::optional<OString> const type;
        ::o3tl::optional<OString> const type;
        Literal(OString const& i_rValue, OString const& i_rLanguage,
                ::boost::optional<OString> const& i_rType)
                ::o3tl::optional<OString> const& i_rType)
            : value(i_rValue)
            , language(i_rLanguage)
            , type(i_rType)
@@ -2221,7 +2221,7 @@ librdf_TypeConverter::extractNode_NoLock(
        OUStringToOString(xLiteral->getLanguage(),
        RTL_TEXTENCODING_UTF8) );
    const uno::Reference< rdf::XURI > xType(xLiteral->getDatatype());
    boost::optional<OString> type;
    o3tl::optional<OString> type;
    if (xType.is())
    {
        type =
diff --git a/vbahelper/inc/pch/precompiled_msforms.hxx b/vbahelper/inc/pch/precompiled_msforms.hxx
index 2c41fe9..8ae3b5f 100644
--- a/vbahelper/inc/pch/precompiled_msforms.hxx
+++ b/vbahelper/inc/pch/precompiled_msforms.hxx
@@ -43,7 +43,7 @@
#include <type_traits>
#include <utility>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <boost/property_tree/ptree.hpp>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
diff --git a/vcl/inc/bitmapwriteaccess.hxx b/vcl/inc/bitmapwriteaccess.hxx
index 02ca3f9..0cb7fbf 100644
--- a/vcl/inc/bitmapwriteaccess.hxx
+++ b/vcl/inc/bitmapwriteaccess.hxx
@@ -14,7 +14,7 @@
#include <vcl/alpha.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/bitmapaccess.hxx>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess>
    BitmapScopedWriteAccess;
@@ -83,8 +83,8 @@ public:
    void DrawRect(const tools::Rectangle& rRect);

private:
    boost::optional<BitmapColor> mpLineColor;
    boost::optional<BitmapColor> mpFillColor;
    o3tl::optional<BitmapColor> mpLineColor;
    o3tl::optional<BitmapColor> mpFillColor;

    BitmapWriteAccess() = delete;
    BitmapWriteAccess(const BitmapWriteAccess&) = delete;
diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index b4d7da6..03663e0 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -30,7 +30,7 @@
#include <tools/fontenum.hxx>
#include <vcl/glyphitem.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <unordered_map>
#include <memory>

@@ -103,7 +103,7 @@ private:
    hb_font_t* m_pHbFont;
    double m_nAveWidthFactor;
    rtl::Reference<PhysicalFontFace> m_pFontFace;
    boost::optional<bool> m_xbIsGraphiteFont;
    o3tl::optional<bool> m_xbIsGraphiteFont;
};

inline hb_font_t* LogicalFontInstance::GetHbFont()
diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx
index aad967c..d1b9eaf 100644
--- a/vcl/inc/pch/precompiled_vcl.hxx
+++ b/vcl/inc/pch/precompiled_vcl.hxx
@@ -50,7 +50,7 @@
#include <boost/functional/hash.hpp>
#include <boost/math/special_functions/sinc.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/conditn.hxx>
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 8c7e4aa..985ad5623e 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -489,8 +489,8 @@ constexpr sal_uInt32 T_CFF  = 0x43464620;
#endif

    bool VCL_DLLPUBLIC getTTCoverage(
        boost::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> & rUnicodeCoverage,
        boost::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> & rCodePageCoverage,
        o3tl::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> & rUnicodeCoverage,
        o3tl::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> & rCodePageCoverage,
        const unsigned char* pTable, size_t nLength);

/**
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 1810827..f95b613 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -135,10 +135,10 @@ struct ImplSVAppData
    SVAppKeyListeners       maKeyListeners;       // listeners for key events only (eg, extended toolkit)
    std::vector<ImplPostEventPair> maPostedEventList;
    ImplAccelManager*       mpAccelMgr;           // Accelerator Manager
    boost::optional<OUString> mxAppName;            // Application name
    boost::optional<OUString> mxAppFileName;        // Abs. Application FileName
    boost::optional<OUString> mxDisplayName;        // Application Display Name
    boost::optional<OUString> mxToolkitName;        // Toolkit Name
    o3tl::optional<OUString> mxAppName;            // Application name
    o3tl::optional<OUString> mxAppFileName;        // Abs. Application FileName
    o3tl::optional<OUString> mxDisplayName;        // Application Display Name
    o3tl::optional<OUString> mxToolkitName;        // Toolkit Name
    Help*                   mpHelp = nullptr;               // Application help
    VclPtr<PopupMenu>       mpActivePopupMenu;              // Actives Popup-Menu (in Execute)
    VclPtr<ImplWheelWindow> mpWheelWindow;                  // WheelWindow
diff --git a/vcl/inc/unx/screensaverinhibitor.hxx b/vcl/inc/unx/screensaverinhibitor.hxx
index 7100a88..fcc6f49 100644
--- a/vcl/inc/unx/screensaverinhibitor.hxx
+++ b/vcl/inc/unx/screensaverinhibitor.hxx
@@ -16,24 +16,24 @@
#include <rtl/ustring.hxx>
#include <vcl/dllapi.h>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class VCL_PLUGIN_PUBLIC ScreenSaverInhibitor
{
public:
    void inhibit( bool bInhibit, const OUString& sReason,
                  bool bIsX11, const boost::optional<unsigned int>& xid, boost::optional<Display*> pDisplay );
                  bool bIsX11, const o3tl::optional<unsigned int>& xid, o3tl::optional<Display*> pDisplay );

private:
    // These are all used as guint, however this header may be included
    // in kde/tde/etc backends, where we would ideally avoid having
    // any glib dependencies, hence the direct use of unsigned int.
    boost::optional<unsigned int> mnFDOCookie; // FDO ScreenSaver Inhibit
    boost::optional<unsigned int> mnFDOPMCookie; // FDO PowerManagement Inhibit
    boost::optional<unsigned int> mnGSMCookie;
    boost::optional<unsigned int> mnMSMCookie;
    o3tl::optional<unsigned int> mnFDOCookie; // FDO ScreenSaver Inhibit
    o3tl::optional<unsigned int> mnFDOPMCookie; // FDO PowerManagement Inhibit
    o3tl::optional<unsigned int> mnGSMCookie;
    o3tl::optional<unsigned int> mnMSMCookie;

    boost::optional<int> mnXScreenSaverTimeout;
    o3tl::optional<int> mnXScreenSaverTimeout;

#if !defined(__sun) && !defined(AIX)
    BOOL mbDPMSWasEnabled;
diff --git a/vcl/inc/wall2.hxx b/vcl/inc/wall2.hxx
index 37cd4fa..ec96d90 100644
--- a/vcl/inc/wall2.hxx
+++ b/vcl/inc/wall2.hxx
@@ -20,14 +20,14 @@
#ifndef INCLUDED_VCL_INC_WALL2_HXX
#define INCLUDED_VCL_INC_WALL2_HXX

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

class ImplWallpaper
{
    friend class Wallpaper;

private:
    boost::optional<tools::Rectangle>  mpRect;
    o3tl::optional<tools::Rectangle>  mpRect;
    std::unique_ptr<BitmapEx>   mpBitmap;
    std::unique_ptr<Gradient>   mpGradient;
    std::unique_ptr<BitmapEx>   mpCache;
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index ab2e149..970e7c5 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -31,7 +31,7 @@
#include <o3tl/typed_flags_set.hxx>
#include <cppuhelper/weakref.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <list>
#include <memory>
#include <vector>
@@ -97,20 +97,20 @@ bool ImplWindowFrameProc( vcl::Window* pInst, SalEvent nEvent, const void* pEven

struct ImplWinData
{
    boost::optional<OUString>
    o3tl::optional<OUString>
                        mpExtOldText;
    std::unique_ptr<ExtTextInputAttr[]>
                        mpExtOldAttrAry;
    boost::optional<tools::Rectangle>
    o3tl::optional<tools::Rectangle>
                        mpCursorRect;
    long                mnCursorExtWidth;
    bool                mbVertical;
    std::unique_ptr<tools::Rectangle[]>
                        mpCompositionCharRects;
    long                mnCompositionCharRects;
    boost::optional<tools::Rectangle>
    o3tl::optional<tools::Rectangle>
                        mpFocusRect;
    boost::optional<tools::Rectangle>
    o3tl::optional<tools::Rectangle>
                        mpTrackRect;
    ShowTrackFlags      mnTrackFlags;
    sal_uInt16          mnIsTopWindow;
@@ -183,9 +183,9 @@ struct ImplFrameData
struct ImplAccessibleInfos
{
    sal_uInt16          nAccessibleRole;
    boost::optional<OUString>
    o3tl::optional<OUString>
                        pAccessibleName;
    boost::optional<OUString>
    o3tl::optional<OUString>
                        pAccessibleDescription;
    VclPtr<vcl::Window> pLabeledByWindow;
    VclPtr<vcl::Window> pLabelForWindow;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 21916ee..070e17a 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -651,8 +651,8 @@ void Qt5Frame::StartPresentation(bool bStart)
// meh - so there's no Qt platform independent solution
// https://forum.qt.io/topic/38504/solved-qdialog-in-fullscreen-disable-os-screensaver
#if QT5_USING_X11
    boost::optional<unsigned int> aRootWindow;
    boost::optional<Display*> aDisplay;
    o3tl::optional<unsigned int> aRootWindow;
    o3tl::optional<Display*> aDisplay;

    if (QX11Info::isPlatformX11())
    {
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 18c6f0f..bf50a81 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -199,7 +199,7 @@ struct ImplStyleData

    BitmapEx                        maPersonaHeaderBitmap; ///< Cache the header bitmap.
    BitmapEx                        maPersonaFooterBitmap; ///< Cache the footer bitmap.
    boost::optional<Color>          maPersonaMenuBarTextColor; ///< Cache the menubar color.
    o3tl::optional<Color>          maPersonaMenuBarTextColor; ///< Cache the menubar color.
};

struct ImplMiscData
@@ -2098,7 +2098,7 @@ enum WhichPersona { PERSONA_HEADER, PERSONA_FOOTER };
}

/** Update the setting of the Persona header / footer in ImplStyleData */
static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFooter, BitmapEx& rHeaderFooterBitmap, boost::optional<Color>& rMenuBarTextColor )
static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFooter, BitmapEx& rHeaderFooterBitmap, o3tl::optional<Color>& rMenuBarTextColor )
{
    uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
    if ( !xContext.is() )
@@ -2191,7 +2191,7 @@ BitmapEx const & StyleSettings::GetPersonaFooter() const
    return mxData->maPersonaFooterBitmap;
}

const boost::optional<Color>& StyleSettings::GetPersonaMenuBarTextColor() const
const o3tl::optional<Color>& StyleSettings::GetPersonaMenuBarTextColor() const
{
    GetPersonaHeader();
    return mxData->maPersonaMenuBarTextColor;
diff --git a/vcl/source/control/quickselectionengine.cxx b/vcl/source/control/quickselectionengine.cxx
index aff324a..5b76b03 100644
--- a/vcl/source/control/quickselectionengine.cxx
+++ b/vcl/source/control/quickselectionengine.cxx
@@ -25,7 +25,7 @@
#include <vcl/settings.hxx>
#include <sal/log.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace vcl
{
@@ -34,7 +34,7 @@ namespace vcl
    {
        ISearchableStringList&              rEntryList;
        OUString                            sCurrentSearchString;
        ::boost::optional< sal_Unicode >    aSingleSearchChar;
        ::o3tl::optional< sal_Unicode >    aSingleSearchChar;
        Timer                               aSearchTimeout;

        explicit QuickSelectionEngine_Data( ISearchableStringList& _entryList )
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index c0c0c70..8c42865 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -2601,8 +2601,8 @@ append(std::bitset<N> & rSet, size_t const nOffset, sal_uInt32 const nValue)
}

bool getTTCoverage(
    boost::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> &rUnicodeRange,
    boost::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> &rCodePageRange,
    o3tl::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> &rUnicodeRange,
    o3tl::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> &rCodePageRange,
    const unsigned char* pTable, size_t nLength)
{
    bool bRet = false;
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx
index 2ffb60b..65da95a 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -57,7 +57,7 @@
#include <svdata.hxx>
#include <bitmaps.hlst>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <algorithm>

diff --git a/vcl/unx/generic/window/screensaverinhibitor.cxx b/vcl/unx/generic/window/screensaverinhibitor.cxx
index 87dd4ab..8c84a3a 100644
--- a/vcl/unx/generic/window/screensaverinhibitor.cxx
+++ b/vcl/unx/generic/window/screensaverinhibitor.cxx
@@ -47,7 +47,7 @@
#include <sal/log.hxx>

void ScreenSaverInhibitor::inhibit( bool bInhibit, const OUString& sReason,
                                    bool bIsX11, const boost::optional<unsigned int>& xid, boost::optional<Display*> pDisplay )
                                    bool bIsX11, const o3tl::optional<unsigned int>& xid, o3tl::optional<Display*> pDisplay )
{
    const char* appname = SalGenericSystem::getFrameClassName();
    const OString aReason = OUStringToOString( sReason, RTL_TEXTENCODING_UTF8 );
@@ -77,7 +77,7 @@ static void dbusInhibit( bool bInhibit,
                  const gchar* service, const gchar* path, const gchar* interface,
                  const std::function<GVariant*( GDBusProxy*, GError*& )>& fInhibit,
                  const std::function<GVariant*( GDBusProxy*, const guint, GError*& )>& fUnInhibit,
                  boost::optional<guint>& rCookie )
                  o3tl::optional<guint>& rCookie )
{
    if ( ( !bInhibit && !rCookie ) ||
         (  bInhibit &&  rCookie ) )
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 0d1348b..91df150 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -1888,8 +1888,8 @@ void GtkSalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nScreen )

void GtkSalFrame::StartPresentation( bool bStart )
{
    boost::optional<guint> aWindow;
    boost::optional<Display*> aDisplay;
    o3tl::optional<guint> aWindow;
    o3tl::optional<Display*> aDisplay;
    if( getDisplay()->IsX11Display() )
    {
        aWindow = widget_get_xid(m_pWindow);
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index 8a2e998..3e2b925 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -23,7 +23,7 @@
#include <unx/fontmanager.hxx>

#include "cairo_gtk3_cairo.hxx"
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

GtkStyleContext* GtkSalGraphics::mpWindowStyle = nullptr;
GtkStyleContext* GtkSalGraphics::mpButtonStyle = nullptr;
diff --git a/vcl/unx/kf5/KF5SalFrame.cxx b/vcl/unx/kf5/KF5SalFrame.cxx
index a212759..ba34839 100644
--- a/vcl/unx/kf5/KF5SalFrame.cxx
+++ b/vcl/unx/kf5/KF5SalFrame.cxx
@@ -40,7 +40,7 @@

#include <svdata.hxx>

#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

KF5SalFrame::KF5SalFrame(KF5SalFrame* pParent, SalFrameStyleFlags nState, bool bUseCairo)
    : Qt5Frame(pParent, nState, bUseCairo)
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx
index 4118955..d0d0a07 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -51,7 +51,7 @@

#include <map>
#include <string>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <ControlCacheKey.hxx>

using namespace std;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 944acf6..b9e3b70 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -2648,7 +2648,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings )
    aStyleSettings.SetUseFlatBorders( false );
    aStyleSettings.SetUseFlatMenus( false );
    aStyleSettings.SetMenuTextColor( ImplWinColorToSal( GetSysColor( COLOR_MENUTEXT ) ) );
    if ( boost::optional<Color> aColor = aStyleSettings.GetPersonaMenuBarTextColor() )
    if ( o3tl::optional<Color> aColor = aStyleSettings.GetPersonaMenuBarTextColor() )
    {
        aStyleSettings.SetMenuBarTextColor( *aColor );
        aStyleSettings.SetMenuBarRolloverTextColor( *aColor );
diff --git a/writerfilter/inc/pch/precompiled_writerfilter.hxx b/writerfilter/inc/pch/precompiled_writerfilter.hxx
index 0277658..be5fe45 100644
--- a/writerfilter/inc/pch/precompiled_writerfilter.hxx
+++ b/writerfilter/inc/pch/precompiled_writerfilter.hxx
@@ -33,7 +33,7 @@
#include <utility>
#include <vector>
#include <boost/logic/tribool.hpp>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 0744c56..27a1d72 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -448,7 +448,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
        {
            style::LineSpacing aSpacing;
            PropertyMapPtr pTopContext = m_pImpl->GetTopContext();
            boost::optional<PropertyMap::Property> aLineSpacingVal;
            o3tl::optional<PropertyMap::Property> aLineSpacingVal;
            if (pTopContext && (aLineSpacingVal = pTopContext->getProperty(PROP_PARA_LINE_SPACING)) )
            {
                aLineSpacingVal->second >>= aSpacing;
@@ -2635,7 +2635,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
    case NS_ooxml::LN_cntxtAlts_cntxtAlts:
    {
        tools::SvRef<TextEffectsHandler> pTextEffectsHandlerPtr( new TextEffectsHandler(nSprmId) );
        boost::optional<PropertyIds> aPropertyId = pTextEffectsHandlerPtr->getGrabBagPropertyId();
        o3tl::optional<PropertyIds> aPropertyId = pTextEffectsHandlerPtr->getGrabBagPropertyId();
        if(aPropertyId)
        {
            writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index d6be09f..9fa2372 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -89,7 +89,7 @@ void DomainMapperTableHandler::startTable(const TablePropertyMapPtr& pProps)

static void lcl_mergeBorder( PropertyIds nId, const PropertyMapPtr& pOrig, const PropertyMapPtr& pDest )
{
    boost::optional<PropertyMap::Property> pOrigVal = pOrig->getProperty(nId);
    o3tl::optional<PropertyMap::Property> pOrigVal = pOrig->getProperty(nId);

    if ( pOrigVal )
    {
@@ -100,8 +100,8 @@ static void lcl_mergeBorder( PropertyIds nId, const PropertyMapPtr& pOrig, const
static void lcl_computeCellBorders( const PropertyMapPtr& pTableBorders, const PropertyMapPtr& pCellProps,
        sal_Int32 nCell, sal_Int32 nRow, bool bIsEndCol, bool bIsEndRow )
{
    boost::optional<PropertyMap::Property> pVerticalVal = pCellProps->getProperty(META_PROP_VERTICAL_BORDER);
    boost::optional<PropertyMap::Property> pHorizontalVal = pCellProps->getProperty(META_PROP_HORIZONTAL_BORDER);
    o3tl::optional<PropertyMap::Property> pVerticalVal = pCellProps->getProperty(META_PROP_VERTICAL_BORDER);
    o3tl::optional<PropertyMap::Property> pHorizontalVal = pCellProps->getProperty(META_PROP_HORIZONTAL_BORDER);

    // Handle the vertical and horizontal borders
    uno::Any aVertProp;
@@ -246,7 +246,7 @@ bool lcl_extractTableBorderProperty(const PropertyMapPtr& pTableProperties, cons
    if (!pTableProperties)
        return false;

    const boost::optional<PropertyMap::Property> aTblBorder = pTableProperties->getProperty(nId);
    const o3tl::optional<PropertyMap::Property> aTblBorder = pTableProperties->getProperty(nId);
    if( aTblBorder )
    {
        OSL_VERIFY(aTblBorder->second >>= rLine);
@@ -380,7 +380,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
            aGrabBag["TablePosition"] <<= aGrabBagTS;
        }

        boost::optional<PropertyMap::Property> aTableStyleVal = m_aTableProperties->getProperty(META_PROP_TABLE_STYLE_NAME);
        o3tl::optional<PropertyMap::Property> aTableStyleVal = m_aTableProperties->getProperty(META_PROP_TABLE_STYLE_NAME);
        if(aTableStyleVal)
        {
            // Apply table style properties recursively
@@ -448,7 +448,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
        }

        // This is the one preserving just all the table look attributes.
        boost::optional<PropertyMap::Property> oTableLook = m_aTableProperties->getProperty(META_PROP_TABLE_LOOK);
        o3tl::optional<PropertyMap::Property> oTableLook = m_aTableProperties->getProperty(META_PROP_TABLE_LOOK);
        if (oTableLook)
        {
            aGrabBag["TableStyleLook"] = oTableLook->second;
@@ -456,7 +456,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
        }

        // This is just the "val" attribute's numeric value.
        const boost::optional<PropertyMap::Property> aTblLook = m_aTableProperties->getProperty(PROP_TBL_LOOK);
        const o3tl::optional<PropertyMap::Property> aTblLook = m_aTableProperties->getProperty(PROP_TBL_LOOK);
        if(aTblLook)
        {
            aTblLook->second >>= rInfo.nTblLook;
@@ -564,7 +564,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
        if ( !m_aCellProperties.empty() && !m_aCellProperties[0].empty() )
        {
            // aLeftBorder already contains tblBorder; overwrite if cell is different.
            boost::optional<PropertyMap::Property> aCellBorder
            o3tl::optional<PropertyMap::Property> aCellBorder
                = m_aCellProperties[0][0]->getProperty(PROP_LEFT_BORDER);
            if ( aCellBorder )
                aCellBorder->second >>= aLeftBorder;
@@ -624,7 +624,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
        // if table is only a single row, and row is set as don't split, set the same value for the whole table.
        if( m_aRowProperties.size() == 1 && m_aRowProperties[0].get() )
        {
            boost::optional<PropertyMap::Property> oSplitAllowed = m_aRowProperties[0]->getProperty(PROP_IS_SPLIT_ALLOWED);
            o3tl::optional<PropertyMap::Property> oSplitAllowed = m_aRowProperties[0]->getProperty(PROP_IS_SPLIT_ALLOWED);
            if( oSplitAllowed )
            {
                bool bRowCanSplit = true;
@@ -770,8 +770,8 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
                    };
                    for (const PropertyIds& rBorder : pBorders)
                    {
                        boost::optional<PropertyMap::Property> oStyleCellBorder = pStyleProps->getProperty(rBorder);
                        boost::optional<PropertyMap::Property> oDirectCellBorder = (*aCellIterator)->getProperty(rBorder);
                        o3tl::optional<PropertyMap::Property> oStyleCellBorder = pStyleProps->getProperty(rBorder);
                        o3tl::optional<PropertyMap::Property> oDirectCellBorder = (*aCellIterator)->getProperty(rBorder);
                        if (oStyleCellBorder && oDirectCellBorder)
                        {
                            // We have a cell border from the table style and as direct formatting as well.
@@ -786,7 +786,7 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
                            }
                            else
                            {
                                boost::optional<PropertyMap::Property> oTableBorder = rInfo.pTableBorders->getProperty(rBorder);
                                o3tl::optional<PropertyMap::Property> oTableBorder = rInfo.pTableBorders->getProperty(rBorder);
                                if (oTableBorder)
                                {
                                    table::BorderLine2 aTableBorder = oTableBorder->second.get<table::BorderLine2>();
@@ -843,7 +843,7 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
                                                 uno::makeAny(rInfo.nBottomBorderDistance ), false);

                // Horizontal merge is not a UNO property, extract that info here to rMerges, and then remove it from the map.
                const boost::optional<PropertyMap::Property> aHorizontalMergeVal = (*aCellIterator)->getProperty(PROP_HORIZONTAL_MERGE);
                const o3tl::optional<PropertyMap::Property> aHorizontalMergeVal = (*aCellIterator)->getProperty(PROP_HORIZONTAL_MERGE);
                if (aHorizontalMergeVal)
                {
                    if (aHorizontalMergeVal->second.get<bool>())
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 3a3b713..e25f55e 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -16,7 +16,7 @@
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include "DomainMapperTableManager.hxx"
#include "BorderHandler.hxx"
#include "CellColorHandler.hxx"
@@ -435,7 +435,7 @@ void DomainMapperTableManager::startLevel( )
    TableManager::startLevel( );

    // If requested, pop the value that was pushed too early.
    boost::optional<sal_Int32> oCurrentWidth;
    o3tl::optional<sal_Int32> oCurrentWidth;
    if (m_bPushCurrentWidth && !m_aCellWidths.empty() && !m_aCellWidths.back()->empty())
    {
        oCurrentWidth = m_aCellWidths.back()->back();
@@ -476,7 +476,7 @@ void DomainMapperTableManager::endLevel( )
    m_aGridSpans.pop_back( );

    // Do the same trick as in startLevel(): pop the value that was pushed too early.
    boost::optional<sal_Int32> oCurrentWidth;
    o3tl::optional<sal_Int32> oCurrentWidth;
    if (m_bPushCurrentWidth && !m_aCellWidths.empty() && !m_aCellWidths.back()->empty())
        oCurrentWidth = m_aCellWidths.back()->back();
    m_aCellWidths.pop_back( );
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f203399..49f9838 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -802,7 +802,7 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleShee
    {
        if(pEntry->pProperties)
        {
            boost::optional<PropertyMap::Property> aProperty =
            o3tl::optional<PropertyMap::Property> aProperty =
                    pEntry->pProperties->getProperty(eId);
            if( aProperty )
            {
@@ -827,7 +827,7 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleShee
        const PropertyMapPtr& pDefaultParaProps = GetStyleSheetTable()->GetDefaultParaProps();
        if ( pDefaultParaProps )
        {
            boost::optional<PropertyMap::Property> aProperty = pDefaultParaProps->getProperty(eId);
            o3tl::optional<PropertyMap::Property> aProperty = pDefaultParaProps->getProperty(eId);
            if ( aProperty )
                return aProperty->second;
        }
@@ -837,7 +837,7 @@ uno::Any DomainMapper_Impl::GetPropertyFromStyleSheet(PropertyIds eId, StyleShee
        const PropertyMapPtr& pDefaultCharProps = GetStyleSheetTable()->GetDefaultCharProps();
        if ( pDefaultCharProps )
        {
            boost::optional<PropertyMap::Property> aProperty = pDefaultCharProps->getProperty(eId);
            o3tl::optional<PropertyMap::Property> aProperty = pDefaultCharProps->getProperty(eId);
            if ( aProperty )
                return aProperty->second;
        }
@@ -872,7 +872,7 @@ uno::Any DomainMapper_Impl::GetAnyProperty(PropertyIds eId, const PropertyMapPtr
    // first look in directly applied attributes
    if ( rContext )
    {
        boost::optional<PropertyMap::Property> aProperty = rContext->getProperty(eId);
        o3tl::optional<PropertyMap::Property> aProperty = rContext->getProperty(eId);
        if ( aProperty )
            return aProperty->second;
    }
@@ -1030,7 +1030,7 @@ static void lcl_AddRangeAndStyle(
    pToBeSavedProperties->SetStartingRange(xParaCursor->getStart());
    if(pPropertyMap)
    {
        boost::optional<PropertyMap::Property> aParaStyle = pPropertyMap->getProperty(PROP_PARA_STYLE_NAME);
        o3tl::optional<PropertyMap::Property> aParaStyle = pPropertyMap->getProperty(PROP_PARA_STYLE_NAME);
        if( aParaStyle )
        {
            OUString sName;
@@ -1360,7 +1360,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
            // over the ones from the numbering styles in Word
            // but in Writer numbering styles have priority,
            // so insert directly into the paragraph properties to compensate.
            boost::optional<PropertyMap::Property> oProperty;
            o3tl::optional<PropertyMap::Property> oProperty;
            const StyleSheetEntryPtr pParent = (!pEntry->sBaseStyleIdentifier.isEmpty()) ? GetStyleSheetTable()->FindStyleSheetByISTD(pEntry->sBaseStyleIdentifier) : nullptr;
            const StyleSheetPropertyMap* pParentProperties = dynamic_cast<const StyleSheetPropertyMap*>(pParent ? pParent->pProperties.get() : nullptr);
            if (!pEntry->sBaseStyleIdentifier.isEmpty())
@@ -2253,7 +2253,7 @@ void DomainMapper_Impl::PushFootOrEndnote( bool bIsFootnote )
        // This adds a hack on top of the following hack to save the style name in the context.
        PropertyMapPtr pTopContext = GetTopContext();
        OUString sFootnoteCharStyleName;
        boost::optional< PropertyMap::Property > aProp = pTopContext->getProperty(PROP_CHAR_STYLE_NAME);
        o3tl::optional< PropertyMap::Property > aProp = pTopContext->getProperty(PROP_CHAR_STYLE_NAME);
        if (aProp)
            aProp->second >>= sFootnoteCharStyleName;

@@ -2729,7 +2729,7 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape 
                // Fix spacing for as-character objects. If the paragraph has CT_Spacing_after set,
                // it needs to be set on the object too, as that's what object placement code uses.
                PropertyMapPtr paragraphContext = GetTopContextOfType( CONTEXT_PARAGRAPH );
                boost::optional<PropertyMap::Property> aPropMargin = paragraphContext->getProperty(PROP_PARA_BOTTOM_MARGIN);
                o3tl::optional<PropertyMap::Property> aPropMargin = paragraphContext->getProperty(PROP_PARA_BOTTOM_MARGIN);
                if(aPropMargin)
                    xProps->setPropertyValue( getPropertyName( PROP_BOTTOM_MARGIN ), aPropMargin->second );
            }
@@ -3233,7 +3233,7 @@ static bool lcl_FindInCommand(
void DomainMapper_Impl::GetCurrentLocale(lang::Locale& rLocale)
{
    PropertyMapPtr pTopContext = GetTopContext();
    boost::optional<PropertyMap::Property> pLocale = pTopContext->getProperty(PROP_CHAR_LOCALE);
    o3tl::optional<PropertyMap::Property> pLocale = pTopContext->getProperty(PROP_CHAR_LOCALE);
    if( pLocale )
        pLocale->second >>= rLocale;
    else
@@ -4514,7 +4514,7 @@ void DomainMapper_Impl::handleIndex
static auto InsertFieldmark(std::stack<TextAppendContext> & rTextAppendStack,
        uno::Reference<text::XFormField> const& xFormField,
        uno::Reference<text::XTextRange> const& xStartRange,
        boost::optional<FieldId> const oFieldId) -> void
        o3tl::optional<FieldId> const oFieldId) -> void
{
    uno::Reference<text::XTextContent> const xTextContent(xFormField, uno::UNO_QUERY_THROW);
    uno::Reference<text::XTextAppend> const& xTextAppend(rTextAppendStack.top().xTextAppend);
@@ -4556,7 +4556,7 @@ static auto InsertFieldmark(std::stack<TextAppendContext> & rTextAppendStack,

static auto PopFieldmark(std::stack<TextAppendContext> & rTextAppendStack,
        uno::Reference<text::XTextCursor> const& xCursor,
        boost::optional<FieldId> const oFieldId) -> void
        o3tl::optional<FieldId> const oFieldId) -> void
{
    if (oFieldId
        && (oFieldId == FIELD_FORMCHECKBOX || oFieldId == FIELD_FORMDROPDOWN))
@@ -6515,7 +6515,7 @@ uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharSt
            }

            // In case numbering rules is not found via a style, try the direct formatting instead.
            boost::optional<PropertyMap::Property> oProp = pContext->getProperty(PROP_NUMBERING_RULES);
            o3tl::optional<PropertyMap::Property> oProp = pContext->getProperty(PROP_NUMBERING_RULES);
            if (oProp)
            {
                xLevels.set(oProp->second, uno::UNO_QUERY);
@@ -6621,7 +6621,7 @@ sal_Int32 DomainMapper_Impl::getCurrentNumberingProperty(const OUString& aProp)
{
    sal_Int32 nRet = 0;

    boost::optional<PropertyMap::Property> pProp = m_pTopContext->getProperty(PROP_NUMBERING_RULES);
    o3tl::optional<PropertyMap::Property> pProp = m_pTopContext->getProperty(PROP_NUMBERING_RULES);
    uno::Reference<container::XIndexAccess> xNumberingRules;
    if (pProp)
        xNumberingRules.set(pProp->second, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index d191c1a..1422b747 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -32,7 +32,7 @@
#include <tuple>
#include <unordered_map>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <ooxml/resourceids.hxx>

@@ -144,7 +144,7 @@ class FieldContext : public virtual SvRefBase

    OUString m_sCommand;
    OUString m_sResult;
    boost::optional<FieldId> m_eFieldId;
    o3tl::optional<FieldId> m_eFieldId;
    bool m_bFieldLocked;

    css::uno::Reference<css::text::XTextField> m_xTextField;
@@ -174,7 +174,7 @@ public:
    const OUString&  GetCommand() const {return m_sCommand; }

    void SetFieldId(FieldId eFieldId ) { m_eFieldId = eFieldId; }
    boost::optional<FieldId> const & GetFieldId() const { return m_eFieldId; }
    o3tl::optional<FieldId> const & GetFieldId() const { return m_eFieldId; }

    void AppendResult(OUString const& rResult) { m_sResult += rResult; }
    const OUString&  GetResult() const { return m_sResult; }
@@ -428,7 +428,7 @@ private:
    css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
    css::uno::Reference<css::container::XNameContainer> m_xPageStyles1;
    // cache next available number, expensive to repeatedly compute
    boost::optional<int> m_xNextUnusedPageStyleNo;
    o3tl::optional<int> m_xNextUnusedPageStyleNo;
    css::uno::Reference<css::text::XText> m_xBodyText;
    css::uno::Reference<css::text::XTextContent> m_xEmbedded;

@@ -960,7 +960,7 @@ public:
    tools::SvRef<SdtHelper> m_pSdtHelper;

    /// Document background color, applied to every page style.
    boost::optional<sal_Int32> m_oBackgroundColor;
    o3tl::optional<sal_Int32> m_oBackgroundColor;

    /**
     * This contains the raw table depth. m_nTableDepth > 0 is the same as
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 7dd903b..7b1916d 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -247,10 +247,10 @@ public:
    std::queue<OUString>& m_rPositivePercentages;
    OUString sAnchorId;
    comphelper::SequenceAsHashMap m_aInteropGrabBag;
    boost::optional<sal_Int32> m_oEffectExtentLeft;
    boost::optional<sal_Int32> m_oEffectExtentTop;
    boost::optional<sal_Int32> m_oEffectExtentRight;
    boost::optional<sal_Int32> m_oEffectExtentBottom;
    o3tl::optional<sal_Int32> m_oEffectExtentLeft;
    o3tl::optional<sal_Int32> m_oEffectExtentTop;
    o3tl::optional<sal_Int32> m_oEffectExtentRight;
    o3tl::optional<sal_Int32> m_oEffectExtentBottom;

    GraphicImport_Impl(GraphicImportType eImportType, DomainMapper& rDMapper, std::pair<OUString, OUString>& rPositionOffsets, std::pair<OUString, OUString>& rAligns, std::queue<OUString>& rPositivePercentages) :
        nXSize(0)
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 62ca40c..f55282f 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -293,7 +293,7 @@ uno::Sequence<beans::PropertyValue> ListLevel::GetLevelProperties(bool bDefaults
        PROP_FIRST_LINE_OFFSET, PROP_LEFT_MARGIN
    };
    for(PropertyIds const & rReadId : aReadIds) {
        boost::optional<PropertyMap::Property> aProp = getProperty(rReadId);
        o3tl::optional<PropertyMap::Property> aProp = getProperty(rReadId);
        if (aProp)
            aNumberingProperties.emplace_back( getPropertyName(aProp->first), 0, aProp->second, beans::PropertyState_DIRECT_VALUE );
        else if (rReadId == PROP_FIRST_LINE_INDENT && bDefaults)
@@ -306,7 +306,7 @@ uno::Sequence<beans::PropertyValue> ListLevel::GetLevelProperties(bool bDefaults
                                              beans::PropertyState_DIRECT_VALUE);
    }

    boost::optional<PropertyMap::Property> aPropFont = getProperty(PROP_CHAR_FONT_NAME);
    o3tl::optional<PropertyMap::Property> aPropFont = getProperty(PROP_CHAR_FONT_NAME);
    if(aPropFont && !isOutlineNumbering())
        aNumberingProperties.emplace_back( getPropertyName(PROP_BULLET_FONT_NAME), 0, aPropFont->second, beans::PropertyState_DIRECT_VALUE );

diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index 4b20839..ff87787 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -132,7 +132,7 @@ private:
    OUString                      m_sNumStyleLink;

    /// list id to use for all derived numbering definitions
    boost::optional<OUString> m_oListId;
    o3tl::optional<OUString> m_oListId;

public:
    typedef tools::SvRef< AbstractListDef > Pointer;
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 226ac35..d6e9794 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -251,11 +251,11 @@ void PropertyMap::Erase( PropertyIds eId )
    Invalidate();
}

boost::optional< PropertyMap::Property > PropertyMap::getProperty( PropertyIds eId ) const
o3tl::optional< PropertyMap::Property > PropertyMap::getProperty( PropertyIds eId ) const
{
    std::map< PropertyIds, PropValue >::const_iterator aIter = m_vMap.find( eId );
    if ( aIter == m_vMap.end() )
        return boost::optional<Property>();
        return o3tl::optional<Property>();
    else
        return std::make_pair( eId, aIter->second.getValue() );
}
@@ -662,7 +662,7 @@ void SectionPropertyMap::ApplySectionProperties( const uno::Reference< beans::XP
    {
        if ( xSection.is() )
        {
            boost::optional< PropertyMap::Property > pProp = getProperty( PROP_WRITING_MODE );
            o3tl::optional< PropertyMap::Property > pProp = getProperty( PROP_WRITING_MODE );
            if ( pProp )
                xSection->setPropertyValue( "WritingMode", pProp->second );
        }
@@ -1299,7 +1299,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
        if ( pLastContext )
        {
            bool bIsLandscape = false;
            boost::optional< PropertyMap::Property > pProp = getProperty( PROP_IS_LANDSCAPE );
            o3tl::optional< PropertyMap::Property > pProp = getProperty( PROP_IS_LANDSCAPE );
            if ( pProp )
                pProp->second >>= bIsLandscape;

@@ -1446,7 +1446,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )

        //prepare text grid properties
        sal_Int32 nHeight = 1;
        boost::optional< PropertyMap::Property > pProp = getProperty( PROP_HEIGHT );
        o3tl::optional< PropertyMap::Property > pProp = getProperty( PROP_HEIGHT );
        if ( pProp )
            pProp->second >>= nHeight;

@@ -1487,7 +1487,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
        const StyleSheetEntryPtr pEntry = rDM_Impl.GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( "Standard" );
        if ( pEntry.get() )
        {
            boost::optional< PropertyMap::Property > pPropHeight = pEntry->pProperties->getProperty( PROP_CHAR_HEIGHT_ASIAN );
            o3tl::optional< PropertyMap::Property > pPropHeight = pEntry->pProperties->getProperty( PROP_CHAR_HEIGHT_ASIAN );
            if ( pPropHeight )
            {
                double fHeight = 0;
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index 64e9969..b760330 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -28,7 +28,7 @@
#include <com/sun/star/uno/Any.h>
#include "PropertyIds.hxx"
#include <memory>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#include <map>
#include <vector>
#include "TagLogger.hxx"
@@ -149,7 +149,7 @@ public:
    void InsertProps( const PropertyMapPtr& rMap, const bool bOverwrite = true );

    // Returns a copy of the property if it exists, .first is its PropertyIds and .second is its Value (type css::uno::Any)
    boost::optional< Property > getProperty( PropertyIds eId ) const;
    o3tl::optional< Property > getProperty( PropertyIds eId ) const;

    // Has the property named been set (via Insert)?
    bool isSet( PropertyIds eId ) const;
@@ -215,7 +215,7 @@ private:
    css::uno::Reference< css::beans::XPropertySet > m_aFirstPageStyle;
    css::uno::Reference< css::beans::XPropertySet > m_aFollowPageStyle;

    boost::optional< css::table::BorderLine2 >      m_oBorderLines[4];
    o3tl::optional< css::table::BorderLine2 >      m_oBorderLines[4];
    sal_Int32                                       m_nBorderDistances[4];
    BorderApply                                     m_eBorderApply;
    BorderOffsetFrom                                m_eBorderOffsetFrom;
diff --git a/writerfilter/source/dmapper/SdtHelper.cxx b/writerfilter/source/dmapper/SdtHelper.cxx
index aef7ac1..bdd82cc 100644
--- a/writerfilter/source/dmapper/SdtHelper.cxx
+++ b/writerfilter/source/dmapper/SdtHelper.cxx
@@ -42,11 +42,11 @@ static awt::Size lcl_getOptimalWidth(const StyleSheetTablePtr& pStyleSheet,

    PropertyMapPtr pDefaultCharProps = pStyleSheet->GetDefaultCharProps();
    vcl::Font aFont(pOut->GetFont());
    boost::optional<PropertyMap::Property> aFontName
    o3tl::optional<PropertyMap::Property> aFontName
        = pDefaultCharProps->getProperty(PROP_CHAR_FONT_NAME);
    if (aFontName)
        aFont.SetFamilyName(aFontName->second.get<OUString>());
    boost::optional<PropertyMap::Property> aHeight
    o3tl::optional<PropertyMap::Property> aHeight
        = pDefaultCharProps->getProperty(PROP_CHAR_HEIGHT);
    if (aHeight)
    {
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 4c05506..7c47732 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -112,10 +112,10 @@ void TableStyleSheetEntry::AddTblStylePr( TblStyleType nType, const PropertyMapP
        if ( nType == pTypesToFix[i] )
        {
            PropertyIds nChecked = pPropsToCheck[i];
            boost::optional<PropertyMap::Property> pChecked = pProps->getProperty(nChecked);
            o3tl::optional<PropertyMap::Property> pChecked = pProps->getProperty(nChecked);

            PropertyIds nInsideProp = ( i < 2 ) ? META_PROP_HORIZONTAL_BORDER : META_PROP_VERTICAL_BORDER;
            boost::optional<PropertyMap::Property> pInside = pProps->getProperty(nInsideProp);
            o3tl::optional<PropertyMap::Property> pInside = pProps->getProperty(nInsideProp);

            if ( pChecked && pProps )
            {
@@ -200,7 +200,7 @@ static void lcl_mergeProps( const PropertyMapPtr& pToFill, const PropertyMapPtr&
    for ( unsigned i = 0 ; i != SAL_N_ELEMENTS(pPropsToCheck); i++ )
    {
        PropertyIds nId = pPropsToCheck[i];
        boost::optional<PropertyMap::Property> pProp = pToAdd->getProperty(nId);
        o3tl::optional<PropertyMap::Property> pProp = pToAdd->getProperty(nId);

        if ( pProp )
        {
diff --git a/writerfilter/source/dmapper/TextEffectsHandler.hxx b/writerfilter/source/dmapper/TextEffectsHandler.hxx
index 6a40ed6..b4a7471 100644
--- a/writerfilter/source/dmapper/TextEffectsHandler.hxx
+++ b/writerfilter/source/dmapper/TextEffectsHandler.hxx
@@ -21,7 +21,7 @@
#include <oox/helper/grabbagstack.hxx>

#include <memory>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

namespace writerfilter {
namespace dmapper
@@ -31,7 +31,7 @@ namespace dmapper
class TextEffectsHandler : public LoggedProperties
{
private:
    boost::optional<PropertyIds>         maPropertyId;
    o3tl::optional<PropertyIds>         maPropertyId;
    OUString                             maElementName;
    std::unique_ptr<oox::GrabBagStack> mpGrabBagStack;

@@ -45,7 +45,7 @@ public:
    explicit TextEffectsHandler(sal_uInt32 aElementId);
    virtual ~TextEffectsHandler() override;

    const boost::optional<PropertyIds>& getGrabBagPropertyId() const { return maPropertyId;}
    const o3tl::optional<PropertyIds>& getGrabBagPropertyId() const { return maPropertyId;}

    css::beans::PropertyValue getInteropGrabBag();

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 019b961..99e91aa 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -13,7 +13,7 @@
#include <queue>
#include <tuple>
#include <vector>
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>

#include <com/sun/star/text/WrapTextMode.hpp>
#include <oox/mathml/importutils.hxx>
@@ -274,7 +274,7 @@ private:
    sal_Int32 m_nTop = 0;
    sal_Int32 m_nRight = 0;
    sal_Int32 m_nBottom = 0;
    boost::optional<sal_Int32> m_oZ; ///< Z-Order of the shape.
    o3tl::optional<sal_Int32> m_oZ; ///< Z-Order of the shape.
    sal_Int16 m_nHoriOrientRelation
        = 0; ///< Horizontal text::RelOrientation for drawinglayer shapes.
    sal_Int16 m_nVertOrientRelation = 0; ///< Vertical text::RelOrientation for drawinglayer shapes.
@@ -380,7 +380,7 @@ private:
    sal_Int32 m_nHoriPadding, m_nVertPadding;
    sal_Int32 m_nHoriAlign, m_nHoriAnchor, m_nVertAlign, m_nVertAnchor;
    Id m_nHRule;
    boost::optional<Id> m_oWrap;
    o3tl::optional<Id> m_oWrap;

public:
    explicit RTFFrame(RTFParserState* pParserState);
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 8dc10cc..86cae03 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -373,14 +373,14 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
    uno::Any aLineWidth = uno::makeAny(sal_Int32(26));
    sal_Int16 eWritingMode = text::WritingMode2::LR_TB;
    // Groupshape support
    boost::optional<sal_Int32> oGroupLeft;
    boost::optional<sal_Int32> oGroupTop;
    boost::optional<sal_Int32> oGroupRight;
    boost::optional<sal_Int32> oGroupBottom;
    boost::optional<sal_Int32> oRelLeft;
    boost::optional<sal_Int32> oRelTop;
    boost::optional<sal_Int32> oRelRight;
    boost::optional<sal_Int32> oRelBottom;
    o3tl::optional<sal_Int32> oGroupLeft;
    o3tl::optional<sal_Int32> oGroupTop;
    o3tl::optional<sal_Int32> oGroupRight;
    o3tl::optional<sal_Int32> oGroupBottom;
    o3tl::optional<sal_Int32> oRelLeft;
    o3tl::optional<sal_Int32> oRelTop;
    o3tl::optional<sal_Int32> oRelRight;
    o3tl::optional<sal_Int32> oRelBottom;

    // Importing these are not trivial, let the VML import do the hard work.
    oox::vml::FillModel aFillModel; // Gradient.
@@ -388,8 +388,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap

    bool bOpaque = true;

    boost::optional<sal_Int16> oRelativeWidth;
    boost::optional<sal_Int16> oRelativeHeight;
    o3tl::optional<sal_Int16> oRelativeWidth;
    o3tl::optional<sal_Int16> oRelativeHeight;
    sal_Int16 nRelativeWidthRelation = text::RelOrientation::PAGE_FRAME;
    sal_Int16 nRelativeHeightRelation = text::RelOrientation::PAGE_FRAME;
    boost::logic::tribool obRelFlipV(boost::logic::indeterminate);
@@ -727,7 +727,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
            sal_Int16 nPercentage = rtl::math::round(rProperty.second.toDouble() / 10);
            if (nPercentage)
            {
                boost::optional<sal_Int16>& rPercentage
                o3tl::optional<sal_Int16>& rPercentage
                    = rProperty.first == "pctHoriz" ? oRelativeWidth : oRelativeHeight;
                rPercentage = nPercentage;
            }
diff --git a/xmlscript/inc/pch/precompiled_xmlscript.hxx b/xmlscript/inc/pch/precompiled_xmlscript.hxx
index 3029560..e1f376d 100644
--- a/xmlscript/inc/pch/precompiled_xmlscript.hxx
+++ b/xmlscript/inc/pch/precompiled_xmlscript.hxx
@@ -21,7 +21,7 @@
*/

#if PCH_LEVEL >= 1
#include <boost/optional.hpp>
#include <o3tl/optional.hxx>
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>