diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-07 15:22:54 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-05-08 14:23:05 -0400 |
commit | aac15b638410f181133dc15343136b4e9a1675ba (patch) | |
tree | 8ce171d69b7dd884a546544d53993a61dc6e38e3 | |
parent | c601d86ce154e43266e0185b2fba2c1b4f196d1d (diff) |
Set anchor to XTextContent using UNO API.
Change-Id: Id1ccae62037369917a46d620c0c46ac2447a0910
-rw-r--r-- | editeng/inc/editeng/unonames.hxx | 33 | ||||
-rw-r--r-- | editeng/source/uno/unofield.cxx | 11 | ||||
-rw-r--r-- | editeng/source/uno/unotext.cxx | 8 |
3 files changed, 50 insertions, 2 deletions
diff --git a/editeng/inc/editeng/unonames.hxx b/editeng/inc/editeng/unonames.hxx new file mode 100644 index 000000000000..e7241151aac0 --- /dev/null +++ b/editeng/inc/editeng/unonames.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Kohei Yoshida <kohei.yoshida@suse.com> + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#define UNO_TC_PROP_ANCHOR "Anchor" + +#define UNO_TR_PROP_SELECTION "Selection" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/uno/unofield.cxx b/editeng/source/uno/unofield.cxx index 7b97684275cb..50c578f567ee 100644 --- a/editeng/source/uno/unofield.cxx +++ b/editeng/source/uno/unofield.cxx @@ -41,6 +41,8 @@ #include <comphelper/serviceinfohelper.hxx> #include <comphelper/servicehelper.hxx> +#include "editeng/unonames.hxx" + using namespace ::rtl; using namespace ::cppu; using namespace ::com::sun::star; @@ -671,6 +673,12 @@ void SAL_CALL SvxUnoTextField::setPropertyValue( const OUString& aPropertyName, if( mpImpl == NULL ) throw uno::RuntimeException(); + if (aPropertyName == UNO_TC_PROP_ANCHOR) + { + aValue >>= mxAnchor; + return; + } + const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMap().getByName( aPropertyName ); if ( !pMap ) throw beans::UnknownPropertyException(); @@ -838,6 +846,9 @@ uno::Any SAL_CALL SvxUnoTextField::getPropertyValue( const OUString& PropertyNam { SolarMutexGuard aGuard; + if (PropertyName == UNO_TC_PROP_ANCHOR) + return uno::makeAny(mxAnchor); + uno::Any aValue; const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMap().getByName( PropertyName ); diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index a13bb0ca768f..52d31bb56aae 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -55,7 +55,7 @@ #include <comphelper/serviceinfohelper.hxx> #include <comphelper/servicehelper.hxx> -#define UNO_TR_PROP_SELECTION "Selection" +#include "editeng/unonames.hxx" using namespace ::rtl; using namespace ::cppu; @@ -1821,7 +1821,11 @@ void SAL_CALL SvxUnoTextBase::insertTextContent( const uno::Reference< text::XTe pForwarder->QuickInsertField(aField, toESelection(aSel)); GetEditSource()->UpdateData(); - pField->SetAnchor( uno::Reference< text::XTextRange >::query( (cppu::OWeakObject*)this ) ); + uno::Reference<beans::XPropertySet> xPropSetContent(xContent, uno::UNO_QUERY); + if (!xContent.is()) + throw lang::IllegalArgumentException(); + + xPropSetContent->setPropertyValue(UNO_TC_PROP_ANCHOR, uno::makeAny(xRange)); aSel.End.PositionInParagraph += 1; aSel.Start.PositionInParagraph = aSel.End.PositionInParagraph; |