Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / source / svdraw / svdoutl.cxx
blob02bb89e38bda5f5abbf673fadf76899c2a25e7cb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <optional>
21 #include <svx/svdoutl.hxx>
22 #include <editeng/outliner.hxx>
23 #include <svx/svdmodel.hxx>
24 #include <svx/svdotext.hxx>
25 #include <svx/svdpage.hxx>
26 #include <editeng/editstat.hxx>
27 #include <svl/itempool.hxx>
28 #include <editeng/editview.hxx>
31 SdrOutliner::SdrOutliner( SfxItemPool* pItemPool, OutlinerMode nMode )
32 : Outliner( pItemPool, nMode ),
33 mpVisualizedPage(nullptr)
38 SdrOutliner::~SdrOutliner()
43 void SdrOutliner::SetTextObj( const SdrTextObj* pObj )
45 if( pObj && pObj != mxWeakTextObj.get().get() )
47 SetUpdateLayout(false);
48 OutlinerMode nOutlinerMode2 = OutlinerMode::OutlineObject;
49 if ( !pObj->IsOutlText() )
50 nOutlinerMode2 = OutlinerMode::TextObject;
51 Init( nOutlinerMode2 );
53 setGlobalScale(100.0, 100.0, 100.0, 100.0);
55 EEControlBits nStat = GetControlWord();
56 nStat &= ~EEControlBits( EEControlBits::STRETCHING | EEControlBits::AUTOPAGESIZE );
57 SetControlWord(nStat);
59 Size aMaxSize( 100000,100000 );
60 SetMinAutoPaperSize( Size() );
61 SetMaxAutoPaperSize( aMaxSize );
62 SetPaperSize( aMaxSize );
63 SetTextColumns(pObj->GetTextColumnsNumber(), pObj->GetTextColumnsSpacing());
64 ClearPolygon();
67 mxWeakTextObj = const_cast< SdrTextObj* >(pObj);
70 void SdrOutliner::SetTextObjNoInit( const SdrTextObj* pObj )
72 mxWeakTextObj = const_cast< SdrTextObj* >(pObj);
75 OUString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_Int32 nPos,
76 std::optional<Color>& rpTxtColor, std::optional<Color>& rpFldColor,
77 std::optional<FontLineStyle>& rpFldLineStyle)
79 bool bOk = false;
80 OUString aRet;
82 if(auto pTextObj = mxWeakTextObj.get())
83 bOk = pTextObj->CalcFieldValue(rField, nPara, nPos, false, rpTxtColor, rpFldColor, rpFldLineStyle, aRet);
85 if (!bOk)
86 aRet = Outliner::CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor, rpFldLineStyle);
88 return aRet;
91 const SdrTextObj* SdrOutliner::GetTextObj() const
93 return mxWeakTextObj.get().get();
96 bool SdrOutliner::hasEditViewCallbacks() const
98 for (size_t a(0); a < GetViewCount(); a++)
100 OutlinerView* pOutlinerView = GetView(a);
102 if (pOutlinerView && pOutlinerView->GetEditView().getEditViewCallbacks())
104 return true;
108 return false;
111 std::optional<bool> SdrOutliner::GetCompatFlag(SdrCompatibilityFlag eFlag) const
113 if( mpVisualizedPage )
115 return {mpVisualizedPage->getSdrModelFromSdrPage().GetCompatibilityFlag(eFlag)};
117 return {};
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */